You need to sign in to do that
Don't have an account?
Janno Rip
Custom Button that checks through every entry beforce execute
Hello Community,
I need to create a onClick JavaScript Button that switches a custom field on my custom object to a specific value. Now here’s the trick part: It should only execute if no other related objects have already that value.
Example:
My custom object is leadevent__c and has a lookup to account. Therefore it is a related list. I have a custom field Phase__c with a value called "in Bearbeitung". I only want to allow 1 leadevent to be in the Phase__ "in Bearbeitung" at a time. Now on the page of the leadevent I already have a button called "Akzeptieren" (Accept) that switches my Phase__c to "in Bearbeitung". However before that happens the button should query through all other leadevents who relate to that account and check if any of them is already in the Phase__c "in Bearbeitung". If so, a simple alert would be enough. If not, the Phase__c should change.
Is that possible? Im a just in at the beginning of my travel in figuring out what is possible in Salesforce. Hope someone can help.
Greetings from Germany
I need to create a onClick JavaScript Button that switches a custom field on my custom object to a specific value. Now here’s the trick part: It should only execute if no other related objects have already that value.
Example:
My custom object is leadevent__c and has a lookup to account. Therefore it is a related list. I have a custom field Phase__c with a value called "in Bearbeitung". I only want to allow 1 leadevent to be in the Phase__ "in Bearbeitung" at a time. Now on the page of the leadevent I already have a button called "Akzeptieren" (Accept) that switches my Phase__c to "in Bearbeitung". However before that happens the button should query through all other leadevents who relate to that account and check if any of them is already in the Phase__c "in Bearbeitung". If so, a simple alert would be enough. If not, the Phase__c should change.
Is that possible? Im a just in at the beginning of my travel in figuring out what is possible in Salesforce. Hope someone can help.
Greetings from Germany
What you could do here is use a Flow instead of a Javascript button. Flows have the ability to query the database for any additional records where the Phase is In Bearbeitung and count how many results you have. If the number of results is 0, the flow can change the phase to Offen - otherwise, it could display a warning. The flow will need to have one input variable called record Id - this is so it knows which record to update.
Once you build the flow, you can create a quick action or a button to launch it from the page layout.
Hope this helps.
Thanks,
Nagendra