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
Vinod Kumar BandaruVinod Kumar Bandaru 

How to identify trigger called from Standard PageLayout or form seperate DML statement in code

Hello All,

I have a scenario that i need to identify in trigger,whether Account record got updated from Standard layout or from any DML statement. Here i am using standard layout. Account will update using DML from many places aswell.

Can anyone provide some suggestions on this.
David Zhu 🔥David Zhu 🔥
You may have to add a custom field (i.e isFromDML checkbox type)  on Account object. Do NOT  add it to the page layout. When doing DML, set the value to true. By this, you can differentiate this  in trigger form standard page layout or DML code.
Agustin BAgustin B
Hi Vinod, from standard fields you cant know the difference, maybe when you use a DML statement you could update a custom field saying that it is from DML to be able to know the difference inside the trigger.

If it helps please mark as correct, it may help others
firdoss mohd 1firdoss mohd 1
Hi Vinod,

It looks like our team of experts can help you resolve this ticket. We have Salesforce global help-desk support and you can log a case and our Customer Success Agents will help you solve this issue. You can also speak to them on live chat. Click on the below link to contact our help-desk. Trust me it is a support service that we are offering for free!

https://jbshelpdesk.secure.force.com

Thanks,
Jarvis SFDC team
Vinod Kumar BandaruVinod Kumar Bandaru
Hello @David Zhu 🔥 & Agustin B,

First of all thanks for responding on my question, i really appreciate it. 
Actually i want to give some brief about my Org. It was maintaing in classic and from more than 5 years and there is lot of code, where already DML's present on Account object. But mainting an extra field at those places will not be fusable and in future if any new developer working on Account DML. he need to consider and this will go like continous process.
Here is my requirement
1) For example - we are maintainig 5 felds which will be processed for Outbound call.
2) we should not make outbound untill all fields filled. Whenever user updated from Standard Account Page Layout, if any of these values are null. We are showing some alert from VF page immediately when load happened after update, mentioning the all fields and we are not stoping the update transaction.
3) VF page is maintaining in page layout with height and width as zero. 
4) When account Before trigger called, i am mainting an  reference object for all accounts and there i am mainting a boolean and making it true in Before context.
5) So once Account update completes and while reloading, from VF page controller i am fetching that object and checking the boolean and showing the alert from script in VF page. Alert will be an onetime popup.
6) Once i clicked on 'OK' i am mainting the reference object boolean as false. So again if i reload the page the popup will not show again. Which is perfectly worrking.
7) but here the issue is , the user havent opened Account record and he update some Account child object records. Due to that Account will update and my boolean in reference object is becoming true. 
8) Now if he open acount it s showing alert.
9) So i need to diffrentiate while mainting boolean in my reference object were i am doing in Account Before context.
10) Here if i maintain whether  cursor  came from any DML or from Standard Page layout save button. I  could have complete this requirement.

Any suggestions will be appericiated.