How to pass account value to record producer when clicked on Create Case using case type selector?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
We have Create Case button in Account table. We allow user to create case from Account record by clicking on Create Case button which displays the Case Type Selector page that displays the record producers of all case types. When user selects any one record producer that has the account variable, it must auto populate the account from which Create Case was clicked. But it's not working. When we dont have any record producer and directly displays the sn_customerservice_case.do, it displays the account. How can we auto populate the account using record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @Devangi S
1) When clicking UI action , you can pass the account using Sys_param
Sample code :
UI action to call the record producer
action.setRedirectURL('/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=[sys_id of record producer]&sysparm_recordsysid=' + current.getUniqueValue());
2) In Record producer, create a onload client script to capture the account value and set it to record producer account variable.
Sample code : //change as per your requirement
function onLoad() {
var url = new URLSearchParams(this.location.href);
var recordSysId = url.get('sysparm_recordsysid');
g_form.setValue('parent', recordSysId);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
hey @Devangi S
To auto-populate Account in a Record Producer when clicking Create Case from the Account form, you must explicitly pass and map the context. Record Producers do not automatically inherit URL parameters like standard forms do.
Reason
Opening sn_customerservice_case.do directly works because the platform reads:
sysparm_account=<sys_id>
Record Producers do not auto-bind URL parameters to variables
You must manually handle:
URL - Variable - Target field
Approach
1. Update “Create Case” UI Action
Pass the Account sys_id in the URL:
var url = '/com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=<record_producer_sys_id>' +
'&sysparm_account=' + current.sys_id;
action.setRedirectURL(url);
If using a Case Type Selector page, ensure it also forwards:
sysparm_account=<account_sys_id>
when redirecting to the selected Record Producer.
2. Add Catalog Client Script (onLoad)
This ensures the Account is populated on the form:
function onLoad() {
var accountId = g_request.getParameter('sysparm_account');
if (accountId) {
g_form.setValue('account', accountId);
}
}
Use g_request.getParameter() (reliable for Record Producers)
3. Map Variable to Case Field (Record Producer Script)
(function executeProducerScript(current, producer) {
if (producer.account) {
current.account = producer.account;
}
})(current, producer);**********************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @vaishali231 ,
We are using declarative action form button not UI action. Yes we have declarative action using case type selector page that loads the records producers and once user selects the record producer, it load the record producer in the workspace. Is there any way to pass account to case type selector and then to selected record producer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
Hi @Tanushree Maiti ,
Thanks for the quick response.
We cannot use this approach since the button is the declarative action as shown below. Also there are multiple record producers associated with each case type. We cannot pass static sys ids of the record producers.
