Catalog Client script for mandatory fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 11:44 AM
Hi everyone,
If possible can I please get some expertise on what might be causing a conflict with my catalog client script. Attached and below are the details. The script is making the variables required after submit for users with the pm user role in the platform but not the portal. I need the variables required in both the portal and platform. See attached and below is script
thank you in advance for any feedback you can provide!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 11:50 AM
Hi,
Change the UI Type from Desktop to All to have it run on the portal as well.
Regards,
Niklas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 02:55 PM
The problem is if I select all it does make the fields required on both the portal and the platform but it makes the variables required before it is submitted. I need the variables to only display required after the request is submitted- on both the portal and platform. Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 08:46 PM
Hello Gemma,
Try to execute the
var category = getParameterValue('sysparm_category');
alert(category!='');
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
following script.
//Type appropriate comment here, and begin script below
function onLoad() {
var category = getParameterValue('sysparm_category');
if (category == '') {
// if (g_user.hasRole('pmsubmitter')){
// if (g_user.hasRoleExactly('pmsubmitter')){
if (g_user.hasRoleExactly('pm_user')) {
// g_form.setDisplay('effort_estimate', false);
// g_form.setMandatory('business_need', false);
g_form.setMandatory('business_need', true);
g_form.setMandatory('effort_estimate', true);
g_form.setMandatory('objectives', true);
g_form.setMandatory('key_deliverables', true);
g_form.setMandatory('key_dependencies', true);
g_form.setMandatory('assumptions', true);
g_form.setMandatory('constraints', true);
g_form.setMandatory('risks', true);
g_form.setMandatory('out_of_scope', true);
g_form.setMandatory('workaround_identified', true);
g_form.setMandatory('resource_requirements', true);
g_form.setMandatory('estimated_costs', true);
g_form.setMandatory('project_manager_assignment', true);
} else {
// g_form.setDisplay('effort_estimate', true);
// g_form.setMandatory('business_need', true);
g_form.setMandatory('business_need', false);
g_form.setMandatory('effort_estimate', false);
g_form.setMandatory('objectives', false);
g_form.setMandatory('key_deliverables', false);
g_form.setMandatory('key_dependencies', false);
g_form.setMandatory('assumptions', false);
g_form.setMandatory('constraints', false);
g_form.setMandatory('risks', false);
g_form.setMandatory('out_of_scope', false);
g_form.setMandatory('workaround_identified', false);
g_form.setMandatory('resource_requirements', false);
g_form.setMandatory('estimated_costs', false);
g_form.setMandatory('project_manager_assignment', false);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 10:12 PM
Hi,
These checkboxes controls where to apply the logic. So if you don't want it to run on the Catalog Item but only on the Requested Item then untick this
However, it may be more complex than that. Usually an End User is not viewing the Requested Item on the portal using the ticket form but rather a page with summary widgets just to view it.
Regards,
Niklas