You need to sign in to do that
Don't have an account?
María Jesús Carmona
How can I update a field on Case based on the profileId of the user who created it?
Hi, I wanted to update a field on Case object when that Case's createdByID field refers a user with a profileID "x" or "y" with a static text.
I think that this can be achieved by a trigger that is fired after the Case has been inserted or updated, storing the createdById value on a variable and using it on a query, I tried that but it gives me this error "Illegal assignment from list to set ".
I let my code below:
Maria J.
I think that this can be achieved by a trigger that is fired after the Case has been inserted or updated, storing the createdById value on a variable and using it on a query, I tried that but it gives me this error "Illegal assignment from list to set ".
I let my code below:
trigger myTrigger on Case (after insert, after update) { Set<Id> IdUser =new Set<Id>(); Set<Id> IdProfile =new Set<Id>(); List<Case> caseUpdateList = new List<Case>(); for(Case obj: Trigger.New){ IdUser.add(obj.createdById); IdProfile=[SELECT Id, ProfileID FROM User WHERE User.Id=:IdUser]; IF(IdProfile=='x' || IdProfile=='y'){ //obj.field='created by profile x and y'; } caseUpdateList.add(obj); } IF(caseUpdateList.size() > 0){ update caseUpdateList; } }It will surelly have some code bad written, Im still pretty new to Salesforce and Apex triggers.
Maria J.
Return type of formual is text
All Answers
Please check once below the sample code.
note: I have not tested the above code may you will get some syntactical errors.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Return type of formual is text