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
Dafina BojaDafina Boja 

Lock the contact if the order is approved

I have Orders and Contacts, and is it possible when an order is approved to lock the contact until the event is over.
Abdul KhatriAbdul Khatri
Hi Dafina,

Please elaborate what you mean lock the contact until event is over.
Dafina BojaDafina Boja
Hi Abdul , 

When an order is approved i need automatically the Contact to put in do not contact for example for 5 days or 8 days
AbhishekAbhishek (Salesforce Developers) 
Dafia,

The below blog have a working example for your scenario try it,

https://trailblazers.salesforce.com/answers?id=9063A000000Zkl7QAC


Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks.
Dafina BojaDafina Boja
Hi there, 

That didnt helped me , cause i have different objects , Contacts and Orders.

When an order is approved , i want to lock the contact for example for 3 or 4 days or 1 week.

Thanks
Abdul KhatriAbdul Khatri
Hi Dafina,

Considering you are using Out of Box Order SObject, where you may be using Status field for Approval.

When you say you want to lock the contact record for 3 to 4 days or 1 week, my presumption is from some date on the Order  Sobject or it is until the event is over. How the event and approval duration are related, can you explain please.

Keeping the perspective you are using Out of Box Order SObject, you may be using either BilltoContact or ShiptoContact Id.

Please take a look at the below Approval Class that will help you to lock the Contact either single record or multiple (Bulkify).
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_approval.htm

Once you provide some details and if you need further assistance with the code please let us know Thanks.
Abdul KhatriAbdul Khatri
Hi Dafina, 

Was that helpful?