0

I have an object Inv with status field. There is a visualforce page for this Inv object field operations. That page has a button 'Mark as complete', On clicking this button, Apex code changes Inv.Status__c field to 'Complete'. There is a process builder on this Inv object which checks for this 'Complete' status and Create a record in PT object.

This was already existing project. I am given a requirement to show another visualforce page "VF_page1" (like popup), one of the page parameters of this VF_page1 has to be the Id of the PT record created using the process builder.

Is there a way to get this PT.Id ? Can I do below things using APEX code?

  1. In Apex code, Prevent the process being invoked for the next update
  2. Update the Status to Complete
  3. Pull a few default values which are mentioned in process builder action and Create PT object record in code after setting the default values. This way I will get the newly created PT record Id. I could pass this to the VF_page1.

Please suggest

6
  • Maybe a dumb question, but what is PT? Commented Oct 5, 2017 at 6:58
  • PT is actually another object.
    – Saranya
    Commented Oct 5, 2017 at 7:00
  • Okay, thought you were using an abbreviation - thanks Commented Oct 5, 2017 at 7:01
  • They are abbreviations actually. I am not allowed to share the real object, page name details as per my company policy.
    – Saranya
    Commented Oct 5, 2017 at 7:03
  • Is there any relation between Inv to PT if Yes Then You can SOQL on that with his relations and created date.Hope it will help you. Thanks Regards, Akshay Commented Oct 5, 2017 at 7:10

1 Answer 1

0

Apex is used when you see no ability to solve the issue/requirement with standard out of the box functionalities, guaranteeing maintainability and flexibility of the org.

I see at this point a solution with apex - that you can implement. In general, you would need an extra technical field on the INV object to store the ID. (Here I took the assumption they are both not linked by lookup/master-detail, so completely seperate objects)

  • Create an update trigger that does the PT creation.
  • After the object is created, use the ID to update the technical field. Make sure you make this trigger able to run in batch because of governor limits.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .