You need to sign in to do that
Don't have an account?
Ryan Gardner
Removing a field from an instance of an sObject
I have a class backing a visualforce page for a custom forecasting module. Depending on which user is updating the forecast data, I want to update a different set of fields. In my visualforce I display a list of opportunities, and I want to display all the fields I query for regardless of which user is viewing the forecast, i.e. I can't just not query some fields depending on which user I'm dealing with. It looks something like this:
//define user roles Boolean userIsSalesRep = false; Boolean userIsManager = false; if(boo=foo){ userIsSalesRep = true; }else{ userIsManager = true; }So I have 2 Booleans that show me who I'm dealing with, then I have a method to update the opportunities. When I do the update, I don't want to update certain fields depending on which user is calling the update.
public List<Opportunity> opportunities {get; set;} ...... ...... public void save(){ // I want to do something like this--> if(userIsSalesRep){ for(Opportunity o: opportunities){ o.remove('fieldXX'); } } update(opportunities); }Does anybody have a good idea on how to do this. I have some clunky ideas on what I could do, but I really don't want to make it clunky.
Same applies for manager users too, and I'm assuming you've an option to identify whether the logged in user is Sales Rep or Manager from the trigger as well.