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
Ken sfdc1Ken sfdc1 

Can anyone help me issue with encrypted field as can't use in workflow

please follow this workflow we are trying to create a formula of patient ID by a trigger with the combination of these conditions and fields.We are going for trigger because AEGR_Patient_Initials__c field is converted to encrypted field which is not possible in workflow.

Condition Created and every time edited.
AND(ISPICKVAL($User.AEGR_User_Country__c,"Brazil"),
OR(ISPICKVAL(AEGR_Product__c , "Lomitapide"),
ISPICKVAL(AEGR_Product__c , "Metreleptin"),
ISPICKVAL(AEGR_Product__c , "")),ISPICKVAL( AEGR_Status__c,"Identified" ))

Object : Patient Profile    
Field to Update Patient Profile: Patient ID
Formula value:
IF(ISPICKVAL(AEGR_Product__c , "Lomitapide"), 
AEGR_Patient_Initials__c & "-" & "LOM-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c , "Metreleptin"), 
AEGR_Patient_Initials__c & "-" & "MET-BR" & "-" & TRIM(RIGHT( Name , 4)), 
IF(ISPICKVAL(AEGR_Product__c ,""),"", 
Ken sfdc1Ken sfdc1
Trigger on same object updating patient ID with a formula.
Ken sfdc1Ken sfdc1
trigger PatientIDFieldUpdate on AEGR_Patient_Profile__c (after insert, after update) {

   AEGR_Patient_Profile__c [] updates = new AEGR_Patient_Profile__c[] {};
    for (AEGR_Patient_Profile__c pp: Trigger.new) {
        if (pp.$User.AEGR_User_Country__c == 'Brazil') {
            updates.add(new Opportunity(Id = opp.Id, Opp.OppStatus__c = 'Won'));
        }
    }
    update updates;
}

}