0

There are 2 objects Account(Parent) and Connect(Child) which lookup relationship. When I create an Account, we make a call out where we send the account records to third party application and in response they provide us Party Id and that external id is stamp to Account. So when I create account record, after saving it party id does not update immediately.I have to refresh the page 2 3 times to see the party id.

Now our requirement is whenever we create an account, Connect record should be created automatically and similar to Account, when Connect record is created, we make a call out to third party applications using POST and record gets created to their system and response they provide Party id but condition here is Connect Record gets created to third party applications only when their parent id which is Party Id of account exists in 3rd party applications.

So on After Insert of Account, we have a logic that creates Connect Record. But issue here is When account gets created, party is does not get stamped at the same time as it makes callout and wait for response from 3rd party app and at the same time Connect Record gets created in Salesforce with No party id because Party Id on Account is blank.

On existing Account where party id is present and if I create connect record manually then the child records gets created in 3rd party application because it gets Party Id of Respective Parent.

My concern here is how I control the sequence here? How system will understand while creation of account once party is gets stamped onto then create a child record so that child records gets created in 3rd party app once it gets an Party Is of Account.

Can someone please suggest better solutions to solve the problem?

0

If understand the requirment correctly.

You want to create "Connect" record only after "PartyId" is populated on Account.

  1. Create Account.
  2. Make callout to fetch "PartyId", which will be asynchronous call (Future Method).
  3. When "PartyId" is updated, create Connect Record (After Update on Account)

If you want to create "Connect" record and then update "PartyId". you can choose the below flow

  1. Create Account.
  2. Create Connect (After Insert)
  3. Make callout to fetch "PartyId", which will be asynchronous call (Future Method).
  4. Update "PartyId" from Account to "Connect" (After Update on Account)
4
  • Party id of Account is different than party of Connect. It’s unique id that we receive from 3rd party applications. We use Quable Class to make callout – Dhananjay Patil Nov 21 '19 at 11:02
  • Ohk.., In that case.., Create Account, In After Insert create "Connect" record, after "Connect" record creation method (In Salesforce), call Queueable Class (Async call that populates - PartyId) and enqueue 3rd party Connect record creation Job (Chaining Jobs) – Veera G Nov 21 '19 at 11:22
  • Party Id Populates onto when Record gets created we can not get party id on update operations . Neither we update party id separately – Dhananjay Patil Nov 21 '19 at 11:25
  • Alternatively, You can create 3 Queueable Jobs - 1. Fetching PartyId on Account and Updating Account. 2. Creating Connect record 3. Creating Connect record in 3rd Party. In After Insert of Account, Call Queueable classes in Chains [Chaining Jobs]. Let me know if this helps.. – Veera G Nov 21 '19 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.