Sugar Integrate: How to make run other procedure

I want write procedure where i want to write steps which will execute / run other procedure.
Basically, I want to check (in the main procedure) if the 1st procedure is running then do not execute second procedure. Once the 1st procedure is over then execute second procedure.
For that I will use the Platform request API.
All procedures are (1st and second are manual procedures).
So, to achieve the above task first i need to start 1st procedure within main procedure. For that i was looking for API where i can just provide the procedure ID and it should run.
Here will be my pseudocode.
1) I already have 2 procedures written. In the main procedure using API start 1st procedure
2) set a flag initially set to true. Using JavaScript filter.
3) use the platform API request to check executions. If any execution is pending, then keep the flag same as true else set it to false.
4) Repeat 2 . (With this once the flag is false it will come out)
5) Once the flag is false i can run the second procedure
6) Set the second flag to true
7) use the platform API request to check executions. If any execution is pending, then keep the flag same as true else set it to false.
6) Repeat 2 . (With this once the flag is false it will come out)
Both procedures will perform adding sugar accounts to Sap Customers (with NextPage token logic implemented).
Now my problem is how to run procedures using api (in steps).
Regards,
Ashok
  • Is there a way to use a callback function pattern?

    Pass the name of the second function as a parameter to the first function and then call the second function at the end of the first function.

  • Hi Ashok,

    A similar pattern is used in some of the Sugar Integrate Templates. Basically, there are parent procedures that will store the ID for any child procedure instances as configuration parameters on the parent procedure instance. All the child procedure instances are created and invoked by using platform APIs. (Ex. POST /formulas/instances/:id/executions allows you to run a manually triggered procedure instance.)

    Check out the CRM Data Migrator for Sales as one example.

    support.sugarcrm.com/.../

  • Thanks Matt,

    I can start execution of platform API request (i.e. /formulas/instances/452198/executions) procedure with POST method.

    My main procedure name is mp_mainProcedure_test1 and procedure which i am trying to execute is "sp_SugarToSAP_Accounts_release_3.0".

    I am trying to just start the sp_SugarToSAP_Accounts_release_3.0 procedure. This procedure has all logics i.e. next page token, storing last sync date, checking if Card code Exist then create else update into SAP.

    My observations are.

    1) When try to start procedure sp_SugarToSAP_Accounts_release_3.0 within main procedure (POSTed dummy data i.e. {"abc":"abc"}. It is starting the procedure.

    2) main procedure always gets response status as pending from platform request API.

    3) Checked sp_SugarToSAP_Accounts_release_3.0 executions noticed that execution gets halt and with continue polling

    Any solution so that execution of sp_SugarToSAP_Accounts_release_3.0 should not hold for continue polling and should execute all the next-page token record pages

    Regards,

    Ashok