function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RPalRPal 

wipe out fields when changing the record type

I have requirement to clear out the fields not included in the page layout when I switch from on record type to other. So lets say a record is created for record type 'A' and has 10 fields and when I change the record to record type 'B' which has 6 fields (all these 6 fields are subset of fields in RT 'A') then remaining 4 fields should 'null' out. I know I can do that with a trigger or process builder but in that case I would have to mention each and every field and its relative value. It would be a very long process so I was wondering if there is a simple funtion to do this?
Saravana Muthu 8Saravana Muthu 8
Hi,

You can achieve it using workflow rule.

ISCHANGED(RecordTypeId ) in condtion.

And set the fields to be updated to blank value.

Thanks,
Sarav
Sweet Potato Tec
Gaurish Gopal GoelGaurish Gopal Goel
@Saravana: How you will identify which fields to null out and which fields to leave as they are? The requirement is to null out the fields which are not on the page layout for the selected record type. I think it can't be achieved in a simple way other than trigger and process.
RPalRPal
@saravana: Exactly! I just need to clear the value of only those field which are not on the layout. Do you know any Apex function to achive that other than clearing out the fields individually?
Saravana Muthu 8Saravana Muthu 8
I am not quite sure if this is possible.

Even thought if you use apex you need to specify field names.

Thanks,
Sarav
Sweet Potato Tec