Ui action redirect to Catalog Item form and auto populate the fields
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2025 10:51 PM
Hello,
I have one requirement
We have Pipeline request form under we have Ui action(Travel Plan) so when i click on Ui action so it will redirect me to Catalog Item(Fulfiller Only -Travel request) form and auto populate the fields for Travel plan form. and catalog form will be able to submit. So 4 fields in Travel Plan and Fulfiller Only form is same. so based on user fields value selection it will auto populate in Catalog item form.
So I created one Ui action & redirect to catalog item is working properly but fields not populated and form is not submitting.
Ui Action Script:
var catalogItemName = "Fulfiller Only - Travel Request";
var catalogItemSysId = "";
// Retrieve Catalog Item Sys ID
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('name', catalogItemName);
gr.query();
if (gr.next()) {
catalogItemSysId = gr.getValue('sys_id');
}
// Get field values from the current form
var travelerEID = current.getValue("u_traveler_eid");
var homeCountryLocation = current.getValue("u_home_country_location");
var travelAssignmentCategory = current.getValue("u_travel_assignment_category");
var chargeCode = current.getValue("u_charge_code");
gs.addInfoMessage("my msg value " + travelerEID + " === " + homeCountryLocation + " ===== " + travelAssignmentCategory + " == " + chargeCode);
// Construct the URL for redirection
var catalogURL = "/com.glideapp.servicecatalog_cat_item_view.do?v=1";
catalogURL += "&sysparm_id=" + catalogItemSysId;
catalogURL += "&sysparm_traveler_eid=" + encodeURIComponent(travelerEID);
catalogURL += "&sysparm_home_country_location=" + encodeURIComponent(homeCountryLocation);
catalogURL += "&sysparm_travel_assignment_category=" + encodeURIComponent(travelAssignmentCategory);
catalogURL += "&sysparm_charge_code=" + encodeURIComponent(chargeCode); // Passing charge code
// Redirect the user
gs.addInfoMessage("Redirecting to Create Travel Plan...");
action.setRedirectURL(catalogURL);
0 REPLIES 0