You need to sign in to do that
Don't have an account?

Change status field value on condition
Hi Guys,
Please help me in code.
I have some fields like fName, lNmae,Email, DrivingLiscience etc and a status__c field(values: not opened, in progress, compleated ) .
if all fields are populated then status__c = 'compleated'
else status__c ='inprogress';
Please help me in code.
I have some fields like fName, lNmae,Email, DrivingLiscience etc and a status__c field(values: not opened, in progress, compleated ) .
if all fields are populated then status__c = 'compleated'
else status__c ='inprogress';
You can create a formula field named Status__c and use the below criteria
IF(AND(ISBLANK(fName)),AND(ISBLANK(lNmae)),...."completed","inprogress")
Incase you do not want to create a new formula field for status and just want to update existing field, you can use Workflow rule + field update to achieve this.
See approach mentioned in Https://salesforce.stackexchange.com/questions/74239/formula-to-update-field-with-another-field-value-if-empty/74241
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
i want to do it through class level,
could you please help
As you can accomplish the functionality using the salesforce out of the box functionality, is there any specific reason why you want to go with custom code?
If coding is mandatory, I recommend writing a trigger as mentioned in below article:
https://developer.salesforce.com/forums/?id=906F00000008z93IAA
You need to fetch the desired fields from the SOQL query and loop over trigger.new to check if the fields are null and then update the picklist value to status__c = 'completed'
else status__c ='inprogress'
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you