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
Mahesh sfdc 5Mahesh sfdc 5 

How to validate field data type with populated value using trigger?

how to check field data type with populated value using trigger?
we have an object called data update with below fields,
Field 1 -> Field 1 value
Field 2 -> Field 2 value

Here Field 1 will select from a picklist with label as Field 1 and api name is Field _1__c and Field 1 value is a text field.

And similarly,

Here Field 2 will select from picklist (but object level created as a check box )  with label as Field 2 and api name is Field _2__c and Field 2 value with a text field.

Now how to validate object level field datatype with populated value using trigger.?
Suraj Tripathi 47Suraj Tripathi 47
Hi,

Can you please elaborate more about your requirement?

Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi
Mahesh sfdc 5Mahesh sfdc 5
Like below we have setup on Object,
Object Name: Data_Update__C
Fields:  Field Name 1 (Picklist) ->Here we will select field names like Name,Is_Active__C etc...)
            Field Name 1 Value (Text ) ->Here we will give values of the Field Name 1 field)
            Field Name 2(Picklist) ->Here we will select other fields names Number,date etc...)
            Field Name 1 Value (Text ) ->Here we will give values of the Field Name 2 field
            Object Name : Object name related to Field Name 1 selected value and Field Name 2 selected  value from picklist.

Now we need to validate Field Name 1 select field data type with Field Name 1 Value populated value ,If its a valid its allow to save else throw an error Similarly Field Name 2 .

Exc: Field Name 1 selected as Is_Active__c and Field Name 1 Value is True ->Reccord should save beacuse is_Active__C is a Boolean field
       Field Name 1 selected as Is_Active__c and Field Name 1 Value is "Accept or something elase" ->Reccord should throw an error