You need to sign in to do that
Don't have an account?
Ryan Greene
Error: Field is not writeable (but I'm not trying to write to it)
I am creating a simple trigger to update the Status field if the field 'Last user to view record' equals the Owner ID of the record and the Status currently equals 'New'. The 'Last user to view record' field is a formula which pulls the current Users ID. (So if the User ID matches the Owner ID the status will change to 'Read') What seems to be wrong?
Thanks for your help!
Ryan
Thanks for your help!
Ryan
trigger Read on Web_Links__c (before update) { OwnerId From Web_Links__c]; for(Web_Links__c WI : Trigger.new ){ if(WI.Status__c = 'New'){ if(WI.Last_user_to_view_record__c = WI.OwnerId){ WI.Status__c = 'Read'; } } } }
I think the problem is not the Srarus__c field, it is the if-statement where you are trying to set the field Status__c to 'New'. Comparisons for equality in Apex must use double equal signs. Try this instead: Also make sure the field Status__c is a text field or a picklist field which is assignable (e.g. read/write possible on field level). If Status__c is a formula field then setting a value of Status__c is not possible.
Good luck!
All Answers
I think the problem is not the Srarus__c field, it is the if-statement where you are trying to set the field Status__c to 'New'. Comparisons for equality in Apex must use double equal signs. Try this instead: Also make sure the field Status__c is a text field or a picklist field which is assignable (e.g. read/write possible on field level). If Status__c is a formula field then setting a value of Status__c is not possible.
Good luck!