• LIM AI KHOON
  • NEWBIE
  • 60 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 18
    Replies
Hi, I received this error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger PullSoData caused an unexpected exception, contact your administrator: PullSoData: data changed by trigger for field Sales Order Information: data value too large: (value has been hidden)

I think it is because of this. May I know how to improve this code?
 
//Develop by Wan Nur Atiqah/CR_CRM088

trigger PullSoData on Payment_Term_Credit_Limit__c (before Insert, before update) {
    try{
        double myRinggit = 0;
        double CNYSing = 0;
        double EURODollar = 0;
        
        set<Id> lstId = new set<Id>();
        for(Payment_Term_Credit_Limit__c ob:trigger.new){
            if(ob.Name_of_Customer__c != null){
                lstId.add(ob.Name_of_Customer__c);
            }
        }
        list<Sales_Order__c> lstOb1 =[select Id, Requested_Delivery_Date__c, account__c, Account_SO_No__c,Po_No__c,Total_Qty_Pcs__c,Total_Amount_USD__c,Currency__c, name from Sales_Order__c where Account__c IN :lstId AND Status__c LIKE '%E0005%' and Billed__c=false order by CreatedDate ];
        for(Payment_Term_Credit_Limit__c ob2: trigger.new){
            
            ob2.Sales_Order_Information__c = '';
            ob2.Grand_Total__c = 0;
            ob2.Shipment_Value_SO__c = 0;
            ob2.Shipment_Value_SO_USD__c = 0;
            for(integer i=0; i<lstOb1.size(); i++){
                integer numbering = i+1;
                ob2.Sales_Order_Information__c += '<b>['+numbering+']</b>'+' <b>SO No.:</b> ' + lstOb1[i].name + ', <b>Request Delivery Date:</b> ' + lstOb1[i].Requested_Delivery_Date__c+', <b>Po. No:</b> '+lstOb1[i].Po_No__c+',<b> Total Quantity.pcs: </b>'+lstOb1[i].Total_Qty_Pcs__c+', <b> Total Amount. USD:</b> '+lstOb1[i].Total_Amount_USD__c+', <b>Currency: </b> ' + lstOb1[i].Currency__c + '<Br/>';
                ob2.Grand_Total__c = ob2.Grand_Total__c + lstOb1[i].Total_Amount_USD__c;
                
                if( lstOb1[i].Currency__c!='USD'){
                    ob2.Shipment_Value_SO__c = ob2.Shipment_Value_SO__c + lstOb1[i].Total_Amount_USD__c;
                }else{
                    ob2.Shipment_Value_SO_USD__c = ob2.Shipment_Value_SO_USD__c + lstOb1[i].Total_Amount_USD__c;
                }
            }
        }
        
    }catch(Exception e){
        system.debug('Got error::'+e);
    }
    
}

How to not have a query in for loop? 
 
Hi, I get this error:
System.LimitException: Too many SOQL queries: 101

May I know how to improve this code? Maybe to put query outside the trigger.new loop
trigger pullCommentsApproval on Pricing__c (before update) {
    Map<Id, Pricing__c > oppMap = new Map<Id, Pricing__c >([
        Select (Select Comments From ProcessSteps where StepStatus IN ('Approved','Rejected') ORDER BY CreatedDate DESC) From Pricing__c WHERE Id IN : Trigger.new]);
    
    for(Pricing__c opp: Trigger.new) {
        Pricing__c opp1 = oppMap.get(opp.Id);
        opp.Approver_Comments__c = '';
        for (ProcessInstanceHistory processStep : opp1.ProcessSteps) {
            opp.Approved_Date__c = DateTime.parse(system.now().format());
            
        }
        opp.Approver_Comments3__c = 'aa';
    }
}

 
 Hi, can help me with how to have code coverage for this code?
trigger UpdateRecordOwner on Centive__c (before insert, before update) {
    
    Map<Id, User> userMap = new Map<Id, User>([select id, EmployeeNumber from user where (NOT UserRole.name like'IC%') AND (UserRoleId !=NULL)]);
    
    Map<String, Id> mapEmployeeNoToId = new Map<String, Id>();
    for(User u : userMap.values())
        mapEmployeeNoToId.put(u.EmployeeNumber, u.Id);
    for (Centive__c Centive: Trigger.new){
        if(mapEmployeeNoToId.get(Centive.HOT_Badge_ID__c) !=null)
            Centive.OwnerId = mapEmployeeNoToId.get(Centive.HOT_Badge_ID__c);
        System.debug('MapValue'+ mapEmployeeNoToId.get(Centive.HOT_Badge_ID__c));
        break;
    }
}

 
Hi, in user map have id and name. This code is to check if userMap contains the name from field HOT__C, so the ID from the map will be the owner ID.

The thing is, this code will take the last id from the map, not take the id according to the checking name. May I know how to fix this?
Map<Id, User> userMap = new Map<Id, User>([SELECT Id, Name FROM User where UserRole.name like'HO%']);
for (User u : userMap.values()) {
    for (Centive__c centive: Trigger.new) {
        if(u.Name.contains(centive.HOT__c)){
            centive.OwnerId = u.id;
        } 
    }
}

 
Hi,

I have one scenario, which is 1 staff id cannot be duplicated. in the same year. For example
Staf ID 123 Year__c = 2021 [Accepted]
Staf ID 123 Year__c = 2022 [Accepted]
Staf ID 123 Year__c = 2022 [Not Accepted because already exist in 2022]. May I know how to do that using the validation rule?
 
not(isblank(vlookup( $ObjectType.Incentive__c.Fields.Id, $ObjectType.Incentive__c.Fields.Name,Name))) &&
Id <> vlookup( $ObjectType.Incentive__c.Fields.Id,$ObjectType.Incentive__c.Fields.Name, Name)
This is my current formula, but this does not work like how to suppose to.
 
Hi, I want to create a function where users can mass update their existing data by uploading the CSV file. This is the code. But I get an error.
public class FileUpdate {
    public string nameFile{get;set;}
    public Blob contentFile{get;set;}
    String[] filelines = new String[]{};
    List<Account> accstoupload;

    /***This function reads the CSV file and inserts records into the Account object. ***/
    public Pagereference ReadFile()
    {
        try{
                //Convert the uploaded file which is in BLOB format into a string
                nameFile =blobToString( contentFile,'ISO-8859-1');
                
                //Now sepatate every row of the excel file
                filelines = nameFile.split('\n');
                
                //Iterate through every line and create a Account record for each row
                accstoupload = new List<Account>();
                for (Integer i=1;i<filelines.size();i++)
                {
                    String[] inputvalues = new String[]{};
                    inputvalues = filelines[i].split(',');
                    
                    Account a = new Account();
                    a.Name = inputvalues[0];
                    a.ShippingStreet = inputvalues[1];       
                    a.ShippingCity = inputvalues[2];
                    a.ShippingState = inputvalues[3];
                    a.ShippingPostalCode = inputvalues[4];
                    a.ShippingCountry = inputvalues[5];
        
                    accstoupload.update(a);
                }
         }
         catch(Exception e){
                 ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured reading the CSV file'+e.getMessage());
                ApexPages.addMessage(errormsg);
         }       
        //Finally, insert the collected records
        try{
            insert accstoupload;
        }
        catch (Exception e)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured inserting the records'+e.getMessage());
            ApexPages.addMessage(errormsg);
        }    
        return null;
    }
   
   /**** This function sends back to the visualforce page the list of account records that were inserted ****/ 
    public List<Account> getuploadedAccounts()
    {
        if (accstoupload!= NULL)
            if (accstoupload.size() > 0)
                return accstoupload;
            else
                return null;                    
        else
            return null;
    }  

    public static String blobToString(Blob input, String inCharset){
        String hex = EncodingUtil.convertToHex(input);
        System.assertEquals(0, hex.length() & 1);
        final Integer bytesCount = hex.length() >> 1;
        String[] bytes = new String[bytesCount];
        for(Integer i = 0; i < bytesCount; ++i)
            bytes[i] =  hex.mid(i << 1, 2);
        return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
    }   
}
This is the error
Method does not exist or incorrect signature: void update(Account) from the type List<Account>

I get an error in this line:
accstoupload.update(a);
May I know how to debug this? 
If we want to have a mass upload record from CSV files to salesforce, we can use
accstoupload.add(a);
But why I cannot change from add to update when I want to update the existing records?

 
Hi anyone can help on how to do code coverage for this trigger ? 
This trigger to prevent user submit without image attachment field [rich text field]

Thank you
trigger PraTrigger on RequestApproval__c (before insert, before update) {
    for (RequestApproval__c p:Trigger.new){
    if(p.TSM_Email_c && (String.isBlank(p.Attachmentc) || (String.isNotBlank(p.Attachmentc) && !p.Attachment_c.contains('<img')))){
        p.addError('Picture is required to proceed');
    }
            
}
}

 
Hello, I want to ask, currently my org using USD currency. But our customers are from different countries so will have a few different currencies. As we all know, the currency rate will change from time to time. May I know to convert the USA to their own currency automatically without us changing the rate every time? Is there any way?

At this moment I have one field for the amount in the USA, and 1 field is the customer currency code like MYR, ect. If I do the formula, means we need to update the rate from time to time. Is there any other way to solve this issue?

For this question, I park under the Apex code because I am not sure which section its falls.
Hello,

My case is an Account object that has 2 children. Let's name it object 1 and object 2. Object 1 and 2 has a lookup to account field. So may I know how to retrieve data from object 1 to object 2 where payment status is 'unbill'? 

Account: has field name, ect..
Object 1: has field Name(lookup to account object), item, quantity, total item, payment status, ect...
object 2: has a field Name(lookup to account object), etc...

So every time we create a new form for object 2, it will retrieve data from object 1 that payment status is unbill automatically. Maybe we can retrieve the data in a rich text field?

Is there any trigger code that I can refer to?
 
Hi, I think this question is falls under general development.

Currently, my orgs have an apex class. That class connects with server-PI, where data from SAP will flow to our CRM for an account object [sync function]. Some existing fields are text fields. So now my user requests to change the field from text to picklist. Is it okay if we simply change like usual? because it's already associated with the apex class that captures data from SAP to CRM. If I change that, is it will impact they sync function?
Hi, my case is I have 2 objects, objects 1 and 2 with their own fields. both of them linked with the account name. I want to pull a few data that have the same account name from object one to object 2.

Let's say, Object 1 has 10 records under account Ali, so I want to pull data (item, quantity, total) from this object to object 2 under Ali`s name.

May I know how to do it? Is there any trigger code that I can refer to? If you not really understand the case, kindly let me know.
Hi, kindly assists me to fix my coverage code. My scenario is once users submit a record(parent record), they cannot delete/edit the child record as well. Only the admin can edit or delete. 
trigger preventDelete on ChildRecord__c (before delete) {
    
    Id profileId=userinfo.getProfileId();
    String profileName=[Select Name from Profile where Id=:profileId].Name;
    
    Set < ID > testentry = New Set < ID > ();
    
    for (ChildRecord__c tst: trigger.old) {
        testentry.add(tst.ParentRecord__c );
    }
    
    set<id> mdrRecord = new map<id,ParentRecord__c>([Select Id From ParentRecord__c Where (Approval_Status__c= 'pending' OR Approval_Status__c LIKE '%Approved by%') and Id IN: testentry]).keyset();
    
    for (ChildRecord__c record : trigger.old){
        if (!FeatureManagement.checkPermission('Admin_Can_Delete')){
            
            If(mdrRecord.contains(record.ParentRecord__c)){
                record.addError('This record is locked. If you need to delete it, contact your admin.');
            } 
        }
    }
}
Here is my code coverage. I am not sure why it gives me 0% coverage. 
@isTest (SeeAllData=false)
public class preventDeleteTest {
    
    @isTest
    public static void DeletetestPositive(){
        try {            
            Test.startTest();            
            Profile prof = [SELECT Id FROM Profile WHERE Name = 'Marketer']; //get a profile Id
            User testUser = new User(Alias = 'SLYEODDNG', Email = 'slyeoddng@ve.com.invalid', EmailEncodingKey = 'UTF-8', FirstName = 'YEODDNG', LanguageLocaleKey = 'en_US', LastName = 'SUET LESEDSS', LocaleSidKey = 'en_MY', ProfileId = prof.Id, TimeZoneSidKey = 'Asia/Kuala_Lumpur', Username = 'slyeong@ve.com.devcr'); 
            insert testUser;
            System.runAs(testUser) {
                
                ChildRecord__c MDRLineItem = new ChildRecord__c();
                MDRLineItem.Option__c = 'OEerfrMi';
                MDRLineItem.Product__c = 'Nitrilffee PF Polymer';
                MDRLineItem.Packing_Style__c = '4ff3';
                MDRLineItem.Brand_Name__c = 'gggkkjhk';
                MDRLineItem.Brand_Name_OBM__c= '- N/A -';
                MDRLineItem.Weight_Code__c = 'ENW035';
                MDRLineItem.Colour__c = 'BRN frefBlue';
                MDRLineItem.Flavour__c= 'Leerfmon';
                MDRLineItem.Length__c= '270mm';
                MDRLineItem.Surface__c= 'Double Embossed';
                MDRLineItem.Size__c= 'XrefS';
                MDRLineItem.Manufacturer_OEMi_OBM__c= 'Senterfienxerferfe Sdn.Bhd.';
                MDRLineItem.CE_Cert_Number_OEMi_OBM__c= '- N/A -';
                MDRLineItem.Notify_Body_OEMi_OBM__c= '- N/A -';

                insert MDRLineItem;
                Delete MDRLineItem;
                
                
                //Opportunity createOpp = new Opportunity();
                
                
                //Apex Trigger addError Checking
                ChildRecord__c testResult = [SELECT Id, IsDeleted FROM ChildRecord__c WHERE Id =: MDRLineItem.Id];
                system.debug('testResult.IsDeleted:::'+testResult.IsDeleted);
                system.assertEquals(true, testResult.IsDeleted);
            }
            Test.stopTest();
            
        } catch(Exception e) {
            system.debug('error::'+e);
        }
        
    }
}
Hi, anyone can help me with how to have 100% code coverage for these lines?
 
public static void submitFinalApprovalNo(Id recordId) {
        sObject record = recordId.getSObjectType().newSobject(recordId);
        record.put('Final_Approved__c',false);
        update record;
    }

 
Hi, currently I want to pull comments from the approval process form to a report. Here is my code:
trigger pullCommentsApproval on Return_Shipment__c (before update) {
    
    if(trigger.isUpdate){
          List<Return_Shipment__c> opptyList=[Select id, 
                            (Select Id, 
                             IsPending, 
                             ProcessInstanceId, 
                             TargetObjectId,
                             StepStatus, 
                             OriginalActorId, 
                             ActorId, 
                             RemindersSent,
                             Comments, 
                             IsDeleted, 
                             CreatedDate,
                             CreatedById, 
                             SystemModstamp 
                             From ProcessSteps
                             ORDER BY CreatedDate DESC) 
                            From Return_Shipment__c 
                            WHERE Id IN : Trigger.new];

  if(opptyList.size() > 0){
            for(Return_Shipment__c opp : opptyList){            
                for(Return_Shipment__c opp1 : Trigger.new) {               
                    if(opp.id == opp1.id&& opp1.Final_Approved__c) {               
                        if (opp.ProcessSteps.size() > 0) {
                            opp1.Approver_Comments__c = opp.ProcessSteps[0].Comments;                  
                            opp1.Approver_Comments1__c = opp.ProcessSteps[1].Comments;                    
                            opp1.Approver_Comments2__c = opp.ProcessSteps[2].Comments;                           
                            opp1.Approver_Comments3__c = opp.ProcessSteps[3].Comments;                    
                            opp1.Approver_Comments4__c = opp.ProcessSteps[4].Comments;                           
                        }                           
                    }                        
                }                     
            }        
  }         
    }  
}


Here is the output:
User-added imageAs for now, I have 5 object fields to capture approval comments. One approval, one comment field. However, in real life, it is not necessary for all 5 people to need to approve the form. But this code won't show the comments until the fifth person approves them. 

How I can alter this code to make no matter how many (max 5) people approve the form, the comments are still will be there (in the report?) For example, let say a form needs to be approved by 3 people, so all three comments will be shown in the report. 

Final_Approved__c is a check box to ask approval is it she/ he is the final approval.

Hi, may I know why this code does not change/update the field object data? By default, the field object (Final_Approved__c) is false. The type is a checkbox. This code is in lightning environment js.
. . . 
. . .  
},
    yesButton : function(component,event,helper){
        var result = 'SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId=\''+component.get('v.sObjectInfo.Id')+'\'';
        var approvals = component.get('v.queryResult');
        var newRecords = []; 
        if(approvals != undefined && approvals.length > 0){          						
            var L = new component.get('v.returnShipment'); 	
            L.id ='Return_Shipment__c.Id';  
			L.Final_Approved__c = true; 
			newRecords.push(L);
            component.set("v.returnShipment",newRecords);
			//window.location.reload();
			var approvalID = approvals[0].Id;
			helper.gotoURL(component, '/p/process/ProcessInstanceWorkitemWizardStageManager?id=' + approvals[0].Id, '_self');

        }
    }
This is the code for the component:
<aura:component controller="LCC_App_rej_Return_shipment_cApex" extends="c:LCC_GenericLightningComponent" >
    
    <aura:set attribute="partially" value="false"></aura:set>
	<aura:set attribute="isAdditionalObject" value="false"></aura:set>
    
    <aura:attribute name="queryResult" type="SObject[]" />
    <aura:attribute name="returnShipment" type="Return_Shipment__c" />
    <aura:attribute name="toggleSpinner" type="boolean" default="false"/>    
	
    <aura:handler event="c:LCC_GenericApplicationEvent" action="{!c.apexQuery}"/>
    <aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
    <aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>

    <div>
        <div class="slds-scrollable slds-p-around_medium slds-text-heading_small" id="modal-content-id-1">
            <br/>
            <p>Please confirm if this is FINAL APPROVAL?</p>
            <br/>
            <br/>
        </div>
        <aura:if isTrue="{!v.toggleSpinner}">
                <div role="status" class="slds-spinner slds-spinner_medium slds-spinner_brand" variant="brand">
                    <span class="slds-assistive-text">Loading</span>
                    <div class="slds-spinner__dot-a"></div>
                    <div class="slds-spinner__dot-b"></div>                   
                </div>
        </aura:if> 
        
        <footer class="slds-modal__footer">
            <lightning:button class="slds-button_brand" variant="brand" disabled="{! empty(v.queryResult)}" onclick="{!c.yesButton}" label="Yes"/>
            <lightning:button class="slds-button_brand" variant="brand" disabled="{! empty(v.queryResult)}" onclick="{!c.afterQuery}" label="No"/> 
        </footer>
    </div>
    
    
</aura:component>


 
I want to know how to update check box object field. Currently the check box by default the value is uncheck(false). But I want when user click yes button, the check box object field(yellow highlighted in image) will be change to true. You may refer the image below for better understanding.
User-added imageUser-added imageCurrently I just do as below. But it doesnt work.
{!Return_Shipment__c.Final_Approved__c} == true;
Hi guys,

I have created a button. When user click to the created button, I want it will redirect user to approval/reject page (as attachement). May I know how?
User-added image
Hi, currently when my user click on approve/reject button, it will bring user to a link from flow builder. Once user click the link, it will redirect user to approval page (process approval). Is it possible if the button is directly bring user to approval page (approval process) without go to a page from flows builder?

Please let me know if you need more clarification on this.

Thank you :-)
Hi, I get this error:
System.LimitException: Too many SOQL queries: 101

May I know how to improve this code? Maybe to put query outside the trigger.new loop
trigger pullCommentsApproval on Pricing__c (before update) {
    Map<Id, Pricing__c > oppMap = new Map<Id, Pricing__c >([
        Select (Select Comments From ProcessSteps where StepStatus IN ('Approved','Rejected') ORDER BY CreatedDate DESC) From Pricing__c WHERE Id IN : Trigger.new]);
    
    for(Pricing__c opp: Trigger.new) {
        Pricing__c opp1 = oppMap.get(opp.Id);
        opp.Approver_Comments__c = '';
        for (ProcessInstanceHistory processStep : opp1.ProcessSteps) {
            opp.Approved_Date__c = DateTime.parse(system.now().format());
            
        }
        opp.Approver_Comments3__c = 'aa';
    }
}

 
Hi,

I have one scenario, which is 1 staff id cannot be duplicated. in the same year. For example
Staf ID 123 Year__c = 2021 [Accepted]
Staf ID 123 Year__c = 2022 [Accepted]
Staf ID 123 Year__c = 2022 [Not Accepted because already exist in 2022]. May I know how to do that using the validation rule?
 
not(isblank(vlookup( $ObjectType.Incentive__c.Fields.Id, $ObjectType.Incentive__c.Fields.Name,Name))) &&
Id <> vlookup( $ObjectType.Incentive__c.Fields.Id,$ObjectType.Incentive__c.Fields.Name, Name)
This is my current formula, but this does not work like how to suppose to.
 
Hi, I want to create a function where users can mass update their existing data by uploading the CSV file. This is the code. But I get an error.
public class FileUpdate {
    public string nameFile{get;set;}
    public Blob contentFile{get;set;}
    String[] filelines = new String[]{};
    List<Account> accstoupload;

    /***This function reads the CSV file and inserts records into the Account object. ***/
    public Pagereference ReadFile()
    {
        try{
                //Convert the uploaded file which is in BLOB format into a string
                nameFile =blobToString( contentFile,'ISO-8859-1');
                
                //Now sepatate every row of the excel file
                filelines = nameFile.split('\n');
                
                //Iterate through every line and create a Account record for each row
                accstoupload = new List<Account>();
                for (Integer i=1;i<filelines.size();i++)
                {
                    String[] inputvalues = new String[]{};
                    inputvalues = filelines[i].split(',');
                    
                    Account a = new Account();
                    a.Name = inputvalues[0];
                    a.ShippingStreet = inputvalues[1];       
                    a.ShippingCity = inputvalues[2];
                    a.ShippingState = inputvalues[3];
                    a.ShippingPostalCode = inputvalues[4];
                    a.ShippingCountry = inputvalues[5];
        
                    accstoupload.update(a);
                }
         }
         catch(Exception e){
                 ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured reading the CSV file'+e.getMessage());
                ApexPages.addMessage(errormsg);
         }       
        //Finally, insert the collected records
        try{
            insert accstoupload;
        }
        catch (Exception e)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured inserting the records'+e.getMessage());
            ApexPages.addMessage(errormsg);
        }    
        return null;
    }
   
   /**** This function sends back to the visualforce page the list of account records that were inserted ****/ 
    public List<Account> getuploadedAccounts()
    {
        if (accstoupload!= NULL)
            if (accstoupload.size() > 0)
                return accstoupload;
            else
                return null;                    
        else
            return null;
    }  

    public static String blobToString(Blob input, String inCharset){
        String hex = EncodingUtil.convertToHex(input);
        System.assertEquals(0, hex.length() & 1);
        final Integer bytesCount = hex.length() >> 1;
        String[] bytes = new String[bytesCount];
        for(Integer i = 0; i < bytesCount; ++i)
            bytes[i] =  hex.mid(i << 1, 2);
        return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
    }   
}
This is the error
Method does not exist or incorrect signature: void update(Account) from the type List<Account>

I get an error in this line:
accstoupload.update(a);
May I know how to debug this? 
If we want to have a mass upload record from CSV files to salesforce, we can use
accstoupload.add(a);
But why I cannot change from add to update when I want to update the existing records?

 
Hi, my case is I have 2 objects, objects 1 and 2 with their own fields. both of them linked with the account name. I want to pull a few data that have the same account name from object one to object 2.

Let's say, Object 1 has 10 records under account Ali, so I want to pull data (item, quantity, total) from this object to object 2 under Ali`s name.

May I know how to do it? Is there any trigger code that I can refer to? If you not really understand the case, kindly let me know.
Hi, kindly assists me to fix my coverage code. My scenario is once users submit a record(parent record), they cannot delete/edit the child record as well. Only the admin can edit or delete. 
trigger preventDelete on ChildRecord__c (before delete) {
    
    Id profileId=userinfo.getProfileId();
    String profileName=[Select Name from Profile where Id=:profileId].Name;
    
    Set < ID > testentry = New Set < ID > ();
    
    for (ChildRecord__c tst: trigger.old) {
        testentry.add(tst.ParentRecord__c );
    }
    
    set<id> mdrRecord = new map<id,ParentRecord__c>([Select Id From ParentRecord__c Where (Approval_Status__c= 'pending' OR Approval_Status__c LIKE '%Approved by%') and Id IN: testentry]).keyset();
    
    for (ChildRecord__c record : trigger.old){
        if (!FeatureManagement.checkPermission('Admin_Can_Delete')){
            
            If(mdrRecord.contains(record.ParentRecord__c)){
                record.addError('This record is locked. If you need to delete it, contact your admin.');
            } 
        }
    }
}
Here is my code coverage. I am not sure why it gives me 0% coverage. 
@isTest (SeeAllData=false)
public class preventDeleteTest {
    
    @isTest
    public static void DeletetestPositive(){
        try {            
            Test.startTest();            
            Profile prof = [SELECT Id FROM Profile WHERE Name = 'Marketer']; //get a profile Id
            User testUser = new User(Alias = 'SLYEODDNG', Email = 'slyeoddng@ve.com.invalid', EmailEncodingKey = 'UTF-8', FirstName = 'YEODDNG', LanguageLocaleKey = 'en_US', LastName = 'SUET LESEDSS', LocaleSidKey = 'en_MY', ProfileId = prof.Id, TimeZoneSidKey = 'Asia/Kuala_Lumpur', Username = 'slyeong@ve.com.devcr'); 
            insert testUser;
            System.runAs(testUser) {
                
                ChildRecord__c MDRLineItem = new ChildRecord__c();
                MDRLineItem.Option__c = 'OEerfrMi';
                MDRLineItem.Product__c = 'Nitrilffee PF Polymer';
                MDRLineItem.Packing_Style__c = '4ff3';
                MDRLineItem.Brand_Name__c = 'gggkkjhk';
                MDRLineItem.Brand_Name_OBM__c= '- N/A -';
                MDRLineItem.Weight_Code__c = 'ENW035';
                MDRLineItem.Colour__c = 'BRN frefBlue';
                MDRLineItem.Flavour__c= 'Leerfmon';
                MDRLineItem.Length__c= '270mm';
                MDRLineItem.Surface__c= 'Double Embossed';
                MDRLineItem.Size__c= 'XrefS';
                MDRLineItem.Manufacturer_OEMi_OBM__c= 'Senterfienxerferfe Sdn.Bhd.';
                MDRLineItem.CE_Cert_Number_OEMi_OBM__c= '- N/A -';
                MDRLineItem.Notify_Body_OEMi_OBM__c= '- N/A -';

                insert MDRLineItem;
                Delete MDRLineItem;
                
                
                //Opportunity createOpp = new Opportunity();
                
                
                //Apex Trigger addError Checking
                ChildRecord__c testResult = [SELECT Id, IsDeleted FROM ChildRecord__c WHERE Id =: MDRLineItem.Id];
                system.debug('testResult.IsDeleted:::'+testResult.IsDeleted);
                system.assertEquals(true, testResult.IsDeleted);
            }
            Test.stopTest();
            
        } catch(Exception e) {
            system.debug('error::'+e);
        }
        
    }
}
Hi, anyone can help me with how to have 100% code coverage for these lines?
 
public static void submitFinalApprovalNo(Id recordId) {
        sObject record = recordId.getSObjectType().newSobject(recordId);
        record.put('Final_Approved__c',false);
        update record;
    }

 
Hi guys,

I have created a button. When user click to the created button, I want it will redirect user to approval/reject page (as attachement). May I know how?
User-added image
Hi, currently when my user click on approve/reject button, it will bring user to a link from flow builder. Once user click the link, it will redirect user to approval page (process approval). Is it possible if the button is directly bring user to approval page (approval process) without go to a page from flows builder?

Please let me know if you need more clarification on this.

Thank you :-)