I see this is a pretty common question, and I'm sorry if this exact scenario has been asked before.
I have a case validation trigger that I am using in lieu of standard validation rules. I need to add the following scenario to it, but am having trouble with the logic.
In human terms first: If running user profile is not System Admin or Trading and the status = "trades placed", throw error of "cannot choose this status. if trades are needed, please update status to "Trades Needed*". To add another layer to this, if trading changes the status to "Trades Placed" and changes the owner back to the case submitter, that person should now be able to make any updates on the case.
An easy fix is to create a checkbox of "trades placed" and change that to true once trades are placed, but I'm at all 500 fields for cases with too much effort trying to find one to delete. Just seeing if there is something else I could do. Here is my code thus far:
if((UserInfo.getProfileId() != '00ei0000000KWzj' || UserInfo.getProfileId() != '00ei0000001Mglo') && c.status == 'Trades Placed'))
{
c.addError('You cannot change status to "Trades Placed". If Trades are needed, please update the status to "Trades Needed*"');
}
But there's the obvious issue of the submitter not being able to make any updates to the case once trading is done and assigns the case back to them with the status of "Trades Placed"
Is there any kind of logic possible for this to work - or will I need to find a case field to delete to add "&& c.Trades_Placed__c =! True"?