Salesforce: Create timer on objects - is it possible? - salesforce

The company needs to know how much time each worker spends on each part of each project part.
The following resembles some custom objects that were defined for this app:
Custom Project
Custom Project Part
Custom Time Entry
Now we need to customize our salesforce app in such a way that a worker can open the project part and click "Start..." and later "Stop...".
These buttons would create a time entry with a start date and update the time entry with a stop date respectively.
Is this possible to do in the custom objects themselves? (ideal)
Should we be creating new pages?

Yes. Create two custom Buttons for your custom object eg. "Start" and "Stop". Then put some JavaScript to the buttons to update your custom fields:
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
var YourCustomObject = new sforce.SObject("YourCustomObject__c");
YourCustomObject.Id = '{!YourCustomObject__c.Id }';
YourCustomObject.Start__c = '{!NOW()}';
updateStartTime = sforce.connection.update([YourCustomObject]);
Then insert these buttons to the page layout.

Related

Qlik Sense - create a list or graph that will load a table (QVD Object) when clicking the item

I'm very new into Qlik sense and I want to know if this is possible. So I did a data connection load to load a data into QVD objects (for example 60 tables of districts). When editing a sheet, is it possible to create a list that displays all districts and, when i click on a district, it will load that District table (object) which will expand more graphs that associate to that table? I hope this make sense. Please let me know if i should revise it.
If I understand correctly. You want to load new data when some condition is met (in your case when on district value is selected) right?
If this is the case then I think that you can use Dynamic Views.
Dynamic Views allow you to load specific objects from a template app. So the workflow will be:
prepare template app with all the objects that can be used in another apps. Including the script with placeholders where the selections will be passed
in your main app - include these objects and set a threshold (in your case will be something like count(distinct District) = 1
make selection in the District filed
if the threshold is reached Qlik will pass the selections to the template app, it will reload it and the objects will be populated (how fast the objects will be populated depends on the script reload time of the template app)
Documentation
Video demonstration
P.S.0 Just to mention that Dynamic Views are "subset" of On-Demand App Generation (ODAG). The difference here is that ODAG will produce a new temporary app (again based on the template app) that the user can interact with and dispose whenever is needed (or Qlik will delete if after some specified time)
P.S.1 If your data is not too big and you can allow yourself to load all the data for all Districts then you can use calculation condition for the charts that require only one District to be selected

In salesforce how to add a custom checkbox in pre-existing standard (E.g. User creation) page using Apex?

I want to create a salesforce app. That have trigger on user creation. I need to make it optional by including a checkbox on user creation page.(i.e : the trigger have to start only when my custom checkbox is selected).
How to add custom checkbox in "User creation" page programatically using Apex ?Is it possible or not ?
I tried with MetaData API as :
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
List<MetadataService.Metadata> fields = new List<MetadataService.Metadata>();
MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = 'User.custom_create_field__c';
customField.label = 'Custom created field';
customField.defaultvalue = 'false';
customField.sharingModel = 'ReadWrite';
customField.type_x = 'Checkbox';
fields.add(customField);
MetadataService.AsyncResult[] results = service.create(fields);\\trows session timeout error here
But the last line throws session timeout error. Am I going in correct way to achieve my need? If so how to solve session timeout error?
Why do you want to do this programmatically? What's the problem with adding the checkbox declaratively to the object and to the layouts?
By adding the field to the object metadata as you're doing here, you'll still need to manually add it to layouts to ensure it's available for users to check or uncheck on your user creation page. Adding a new field to all custom layouts is not a trivial exercise, believe me!
However, if you still want to go ahead with this, you should try a different approach. It looks very much to me as though you've taken inspiration from Andy Fawcett here:
https://andyinthecloud.com/2013/10/27/introduction-to-calling-the-metadata-api-from-apex/
You should see the IMPORTANT UPDATE section. The async Metadata API methods were deprecated some time ago, this is the pattern to follow now:
https://andyinthecloud.com/2014/08/14/apex-metadata-api-streamlined-and-simplified-for-summer14/

how to create different UI components every times in runtime and save their contents into database and save the UI which created on the page?

Dears
good day
I need your help for the following case:
The activity nature of the client is very dynamic
Need to have a dynamic form (he wants to create many form every day by himself in runtime). And add some components in the runtime.
He doesn't have a standard form so he need every day to create new form
For example he can make today a form with group of input text and group of check box and table and tomorrow he need to make a new form with input text and radio and table also etc..,.
In addition he needs to achieve and save it into database to use it and retrieve it later , and he wants to save every form with its UI contents which he created in runtime to be able to view it later on the jsf page.
So he want to save created form contains data into database
And also he wants to arrange the component on the page by his own way
And I putted this case in OTN :
https://community.oracle.com/message/14356236#14356236
How could I do it?
Regards
You can find a series of blog posts of Andrejus, right here:
http://andrejusb.blogspot.co.uk/2015/09/adf-12c-dynamic-forms-with-adf-bc-ui.html

React router - different content if post in list vs own page

React router has very cool feature: if you have a list of items (Instagram for example) and if you click on one item, content opens in modal/overlay but if you copy-paste the link to new tab/window or share the link with a friend for example, it opens in its own page.
I would love to use this feature but I need to find a custom solution..
My posts are very data heavy
I've split posts data into 2 tables in database
1st is very lightweight containing essential data: 4-5 columns
2nd table is very heave, ~30 columns
When user uses search filter, list updates only with data from 1st table
If user clicks on post, it will open in a modal/overlay
I will recycle the data I already have (from 1st table) and also get rest of the data from 2nd table
However, when user shares the link or opens it in new tab/page, data from 1st table is not present. I would need to integrate a conditional logic:
If post opens in list view (modal/overlay), only get additinal 2nd table data
If it's opened in a new tab/window in its own page, get all the data, 1st table included
How could I integrate this with React router? Has anyone already tried it? This would also allow to use different layout/components when user opens item in page view. Is there a way to check it?
Or is there a flaw in my logic? I imagine list would update very fast because it doesn't require huge amount of data and also would modal/overlay because it recycles some of the data.
I read all the docs, also searched online - didn't find anything.
Modals in react router are great. I've used the pinterest example and adapted it to my own needs.
Ensure you do your check on state.modal===true in a master layout component to give you the modal styling.
you'll need to check if table 1 stuff is present in your state and dispatch an action to trigger the async call in componentDidMount. You should be fetching table 2 in all scenarios.

Custom Button to copy data from Opportunity into a related custom object

I have a custom object that is used for product setup that is mapped to an opportunity. It's a one to many relationship - one opportunity maps to many setup objects, but one setup object is only mapped to one opportunity.
Opportunity has some setup fields that need to act as defaults for the related custom object. Unfortunately, I cannot just specify them in a formula - getting an error.
What I would like to do is have a custom button that would allow user to click and copy all of the related setup fields from the opportunity into the custom setup object and then edit them as needed.
Any pointers or sample code are greatly appreciated!
You can achieve this with a custom button on the related list for your custom object on the opportunity detail page.
All of the fields on a standard Salesforce new/edit screen have id's associated with them. You can specify values for fields by using these ids to set GET parameters on your URL. For example if the id on the name field on your opportunity is 'opp3', the following URL will populate the name field on your new opportunity page:
https://na2.salesforce.com/006/e?opp3=Hello+World
You would have to change na2 to the correct server for your org.
The new record page URL contains the 3 character id prefix for your particular object and then '/e'. 006 is the prefix for opportunities. You will have to attempt to create a new record to see what the 3 characters are for your custom object.
You will have to capture the id's of the fields you want to populate on your custom object. You can do this by viewing the source of the new record page. For custom fields these id's will take the form of a Salesforce Id (eg. 00N40000002QhEV).
Create a new list button on your custom object and set the behavior to without header and sidebar and set the source to URL. Build up your URL with id=value pairs separated by '&' using the id you got from the page source and the insert field functionality to select the opportunity fields your wish to add in. You should end up with something like this:
/a0U/e?00N40000002QhEV={!Opportunity.Name}&00N40000002QhEW={!Opportunity.StageName}
a0U should be replaced by the correct prefix for your custom object. Then add your button to the related list for your custom object under opportunity.

Resources