Skip to main content

I have created an OmniScript with a step that contains number and edit block element. Edit block element acts as a table to have multiple rows. On clicking next it calls a data raptor which creates a record (using data from number element) for parent object A and multiple records (added via edit block) for child object B. On coming back to the same step and clicking next creates another record instead of updating the same record. I am not getting how I can load the step with records created after clicking next so I can have Ids of the records and I can use them as upsert key in DataRaptor. Is there any way I can have this scenario working in OmniScript by having parent and child information in one step?

#Omnistudio #DataRaptor

1 respuesta
  1. 5 may 2024, 1:58

    Approach 1: Utilizing Output Parameters and Session Variables:

    DataRaptor for Parent Record:

    In your initial DataRaptor that creates the parent record (Object A), add an Output Parameter. Name it something like parentId.

    1. Set the value of this parameter to the ID of the newly created parent record. This can be achieved using Apex code like {!record.Id} within the DataRaptor action.

    Store Parent ID in Session Variable:

    After the DataRaptor action that creates the parent record, use a Set Session Variable element in your OmniScript.

    Set the variable name to something like parentId and its value to the output parameter from the DataRaptor ({!$Flow.parentId}). This stores the parent ID in a session variable accessible throughout the script.

    DataRaptor for Child Records:

    In your DataRaptor that creates child records (Object B), use the {!$Flow.parentId} session variable to reference the ID of the parent record.

    Set the ParentId field on the child records being created to this session variable value.

    Optional: Refresh Step Data (if needed):

    If you need to display information about the newly created records in the same step, consider using a Refresh Step Data element after the DataRaptor actions. This will reload the step data with the updated information.

    Approach 2: Leverage Navigation with Data Parameters:

    DataRaptor for Parent Record:

    Configure your initial DataRaptor to create the parent record as usual.

    Navigation with Data Parameters:

    After creating the parent record, use a Navigate element in your OmniScript.

    In the navigation settings, choose the next step as the target step.

    Set Data Parameters. Create a parameter named parentId and set its value to the ID of the newly created parent record ({!record.Id}).

    Retrieve Data Parameter in Next Step:

    In the next step of your OmniScript, use a Get Data Parameter element.

    Set the parameter name to parentId to retrieve the ID passed from the previous step.

    DataRaptor for Child Records:

    In your DataRaptor that creates child records, use the {!$Flow.parentId} flow variable (populated from the Get Data Parameter element) to reference the ID of the parent record.

    Set the ParentId field on the child records being created to this variable value.

     

    Choosing the Right Approach:

    Approach 1 is simpler for basic scenarios where you don't need to display information about the newly created records in the same step.

    Approach 2 offers more flexibility if you need to access data from the previous step (parent ID) within the current step for display purposes.

0/9000