Passing data on Row Action Event
Data can be passed from the LWC (with the lightning-datatable component) embedded in the Omniscript(OS) to the OS Data JSON to view(/update) the current JSON data in the Omniscript at runtime.
omniApplyCallResp() method
The omniApplyCallResp() method accepts an object that it passes into the OmniScript data JSON. If the root data node name in the response matches an element name in the OmniScript, that data prefills the element, and any nested elements, when it renders in the OmniScript. If the root node name does not match an element in the data JSON, the node inserts into the data JSON immediately. Applying the response works similar to the Send/Response property.
Use case:
In the lightning-datatable, the selected row data can be accessed from the “onrowaction” event handler (in this example, the “onRowAction” method). Now let's see how to pass the selected row data from LWC to the OS Data JSON.
First create a data object with the selected row data. Note that the data from the LWC has to be sent via the node “data”.
Now pass the ‘data’ object as a parameter to the "omniApplyCallResp()” method. This will send the selected row data from the LWC to the Omniscript.
Custom LWC data-table in OS with the button-icons “call” and “user”
onRowAction() which gets triggered on click of button-icons passes data to the OS Data JSON at the runtime
The JSON node used in this example is “SelectedRowId”. The received data json can be used to display data in the UI using Omniscript or Flexcard, or it can be passed to the Dataraptor or the Integration Procedure for further processing.
Now we will see how to display the data passed from the LWC to the OS input elements. The step name (i.e., “SelectedRowId”) and the data JSON node name (i.e., "SelectedRowId") are kept the same to prefill the elements dynamically based on the selected row.
Note: the omniApplyCallResp() can be used to pass the data from LWC to omniscript Data JSON on any events (for example, please refer to the below screenshots for the "onchange" and "onclick" event handlers).
References:
https://help.salesforce.com/s/articleView?id=sf.os_map_responses_to_the_omniscript_s_data_json.htm&type=5