Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Invoking Record Producer within GlideModal

paulmagaling
Tera Contributor

We have a business requirement wherein our client's Finance Team should be able to create Contract Rate Cards within the asset_task form.

 

The agreed approach is to create a Record Producer that will cater the necessary details for the Contract Rate Card. This record producer should pop-up in the asset_task form view if the user updates the asset_task and the state is one of the "Fixed" states.

 

Currently, the record producer has been created, I am just confused on how I can invoke or embed the record producer in a pop-up. Is it possible to invoke the record producer in a GlideModal?

1 ACCEPTED SOLUTION

SawyanPrabha
Kilo Expert

The most common way people do this in Classic UI is to load the Record Producer's rendering page (com.glideapp.servicecatalog_cat_item_view.do or catalog_home.do style URL) inside a GlideModal as an iframe-backed dialog.

function openRateCardProducer() {

    var gm = new GlideModal('glide_modal_frame'); // frame-based modal renders a URL

    gm.setTitle('Create Contract Rate Card');

    gm.setWidth(900);

 

    // sysparm_view / query params can prefill and control layout

    var url = 'com.glideapp.servicecatalog_cat_item_view.do?v=1'

            + '&sysparm_id=<your_record_producer_sys_id>'

            + '&sysparm_asset_task=' + g_form.getUniqueValue(); // pass context

 

    gm.renderWithContent({ url: url });

    // or: gm.setURL(url); gm.render();

}

ssing context (the originating asset_task record) requires you to read query params in the Record Producer script via RP.getParameterValue('sysparm

 

Option 2 (recommended for Classic UI): Trigger on state change + confirm, then open the producer

Since your requirement is "pop-up when the user updates asset_task and the state is one of the Fixed states," split the logic:

  1. onChange / onSubmit Client Script on asset_task detects a Fixed state.
  2. Open the modal (or a confirmation) and then route to / embed the Record Producer.

 

function onSubmit() {

    var state = g_form.getValue('state');

    var fixedStates = ['3', '7', '10']; // your Fixed state values

 

    if (fixedStates.indexOf(state) > -1 && !g_scratchpad.rateCardHandled) {

        openRateCardProducer();

        return false; // stop the submit; let the producer flow drive next steps

    }

}

View solution in original post

1 REPLY 1

SawyanPrabha
Kilo Expert

The most common way people do this in Classic UI is to load the Record Producer's rendering page (com.glideapp.servicecatalog_cat_item_view.do or catalog_home.do style URL) inside a GlideModal as an iframe-backed dialog.

function openRateCardProducer() {

    var gm = new GlideModal('glide_modal_frame'); // frame-based modal renders a URL

    gm.setTitle('Create Contract Rate Card');

    gm.setWidth(900);

 

    // sysparm_view / query params can prefill and control layout

    var url = 'com.glideapp.servicecatalog_cat_item_view.do?v=1'

            + '&sysparm_id=<your_record_producer_sys_id>'

            + '&sysparm_asset_task=' + g_form.getUniqueValue(); // pass context

 

    gm.renderWithContent({ url: url });

    // or: gm.setURL(url); gm.render();

}

ssing context (the originating asset_task record) requires you to read query params in the Record Producer script via RP.getParameterValue('sysparm

 

Option 2 (recommended for Classic UI): Trigger on state change + confirm, then open the producer

Since your requirement is "pop-up when the user updates asset_task and the state is one of the Fixed states," split the logic:

  1. onChange / onSubmit Client Script on asset_task detects a Fixed state.
  2. Open the modal (or a confirmation) and then route to / embed the Record Producer.

 

function onSubmit() {

    var state = g_form.getValue('state');

    var fixedStates = ['3', '7', '10']; // your Fixed state values

 

    if (fixedStates.indexOf(state) > -1 && !g_scratchpad.rateCardHandled) {

        openRateCardProducer();

        return false; // stop the submit; let the producer flow drive next steps

    }

}