Featured Video Play Icon
1 min read

Part 13: Add Onload Client script on the Catalog success page

Add Event handler to capture the params received from catalog page

  • Navigate to Catalog Success Page
  • Create a Client script
  • Set the name as Set request number
  • Set the following script
/**
 * @param {params} params
 * @param {api} params.api
 * @param {any} params.event
 * @param {any} params.imports
 */
function handler({
    api,
    event,
    helpers,
    imports
}) {
    let {
        table,
        sysId,
        number
    } = api.context.props;
    
    api.setState("requestNumber", number);
    api.setState("requestSysId", sysId);
}

Understanding the code snippet

  • We are using restructuring here to extract table, sysId and number from the context props we got from catalog submit event.
  • We are setting state for number and sysId to the params we received.

Hook this client script to the page ready event handler

  • Select Body from the Content section
  • On the properties pane, Click Add a new event handler on Page ready event
  • Select Set request number from the scripts and click Add
  • Click Save on the top to save the page

Great!! We have successfully hooked event catalog success pageand set the state for requestNumber and requestSysId

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.