How do I redirect user to the order status page dynamically from record producer?

KedarB
Tera Contributor

KedarB_0-1713939414787.png

KedarB_1-1713939538598.png

KedarB_2-1713939688393.png

Hi guys, I am trying to redirect the user to the order status page of the request that gets generated when I am submitting a Ui builder form, but after submission it goes to the order status page with an empty request number.

I am using a catalog client script and a script include to do the same.

Could anyone guide me on the possibility of redirecting the users dynamically using the two?

Thanks.

 

 

 

2 ACCEPTED SOLUTIONS

hi @KedarB 
was the link usefull, if yes close the thread so that others will find it easy if they face the same thing.!!! 


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh

View solution in original post

12 REPLIES 12

Few things here, if you just need the sys_id you can get it directly on the client script and secondly g_scratchpad will work with display business rules and not with script include. The 5th line in your client script should be able to get you the sys id.

KedarB_0-1713944779868.png

I tried doing the same but it gives an empty request page, how do I fetch the latest request generated by the current logged in user?

Also, did you get a chance to go through the record producer script that I sent?

 

Here is the code for the cartAPI script in the record producer script from where the request is

generated from the record producer for more clarity.

KedarB_2-1713944194315.png

 

current.setAbortAction(true);
var id = GlideGuid.generate(null);
var caspr_id = gs.getProperty('cisco.caspr.ba.cat.sysid');
var cart = new Cart(id);
var item = cart.addItem(caspr_id);

// Mapping Basic Information Section fields to catalog item fields
cart.setVariable(item, 'name', producer.getValue('name'));
cart.setVariable(item, 'u_service_offering', producer.getValue('u_service_offering'));
cart.setVariable(item, 'u_responsibility_manager', producer.getValue('u_responsibility_manager'));
cart.setVariable(item, 'short_description', producer.getValue('short_description'));
cart.setVariable(item, 'u_business_impact_justification', producer.getValue('u_business_impact_justification'));
cart.setVariable(item, 'install_type', producer.getValue('install_type'));
cart.setVariable(item, 'u_caspr_administration', producer.getValue('u_caspr_administration'));
cart.setVariable(item, 'architecture_type', producer.getValue('architecture_type'));
cart.setVariable(item, 'u_cisco_change_alias', producer.getValue('u_cisco_change_alias'));
cart.setVariable(item, 'use_case', producer.getValue('use_case'));
cart.setVariable(item, 'application_type', producer.getValue('application_type'));
cart.setVariable(item, 'url', producer.getValue('url'));

// Mapping Support and Vendor Information Section fields to catalog item fields
cart.setVariable(item, 'support_manager', producer.getValue('u_support_manager'));
cart.setVariable(item, 'u_support_group', producer.getValue('support_group'));
cart.setVariable(item, 'duty_pager', producer.getValue('u_duty_pager'));
cart.setVariable(item, 'u_business_criticality', producer.getValue('business_criticality'));
cart.setVariable(item, 'u_iaas_provider', producer.getValue('iaas_provider'));
cart.setVariable(item, 'csp_type', producer.getValue('u_caspr_csp_type'));
cart.setVariable(item, 'u_estimated_users', producer.getValue('estimated_users'));
cart.setVariable(item, 'u_user_locations', producer.getValue('user_locations'));
cart.setVariable(item, 'u_french_language_supported', producer.getValue('french_language_supported'));
cart.setVariable(item, 'u_vendor_type', producer.getValue('vendor_type'));
cart.setVariable(item, 'u_new_name', producer.getValue('new_name'));
cart.setVariable(item, 'u_corp_address', producer.getValue('corp_address'));
cart.setVariable(item, 'u_vendor_website', producer.getValue('vendor_website'));
cart.setVariable(item, 'u_duns_number', producer.getValue('duns_number'));
cart.setVariable(item, 'u_vendor_primary_conctact', producer.getValue('vendor_primary_conctact'));
cart.setVariable(item, 'u_vendor_conctact_email', producer.getValue('vendor_conctact_email'));
cart.setVariable(item, 'u_vendor_conctact_role', producer.getValue('vendor_conctact_role'));
cart.setVariable(item, 'u_vendor', producer.getDisplayValue('vendor'));
cart.setVariable(item, 'u_product', producer.getValue('product'));
cart.setVariable(item, 'u_vendor_headquarters', producer.getValue('vendor_headquarters'));
cart.setVariable(item, 'u_vendor_relies_on_third_party', producer.getValue('vendor_relies_on_third_party'));

// Mapping Data Privacy, Protection and Compliance Section fields to catalog item fields
cart.setVariable(item, 'u_data_categories', producer.getValue('data_categories'));
cart.setVariable(item, 'u_data_classification', producer.getValue('data_classification'));
cart.setVariable(item, 'u_pii_categories_of_data_processed_by_vendor', producer.getValue('pii_categories_of_data_processed_by_vendor'));
cart.setVariable(item, 'u_pii_category_level', producer.getValue('pii_category_level'));
cart.setVariable(item, 'u_regulations', producer.getValue('u_regulations'));
cart.setVariable(item, 'u_record_category_and_retention', producer.getValue('record_category_and_retention'));
cart.setVariable(item, 'in_sox_scope', producer.getValue('u_in_sox_scope'));
cart.setVariable(item, 'u_external_privacy_certifications_obtained', producer.getValue('external_privacy_certifications_obtained'));
cart.setVariable(item, 'u_bcr_countries', producer.getValue('bcr_countries'));
cart.setVariable(item, 'u_certs_applied_to_product_or_services', producer.getValue('certs_applied_to_product_or_services'));
cart.setVariable(item, 'u_estimated_number_of_data_subjects', producer.getValue('estimated_number_of_data_subjects'));
cart.setVariable(item, 'u_estimated_users_third_section', producer.getValue('estimated_users_third_section'));
cart.setVariable(item, 'u_where_data_resides', producer.getValue('where_data_resides'));
cart.setVariable(item, 'u_is_data_a_cisco_business_record', producer.getValue('is_data_a_cisco_business_record'));
cart.setVariable(item, 'u_data_deleted_after', producer.getValue('data_deleted_after'));
cart.setVariable(item, 'u_users_create_content', producer.getValue('users_create_content'));
cart.setVariable(item, 'u_system_integration', producer.getValue('system_integration'));
cart.setVariable(item, 'u_free_form_attachments', producer.getValue('free_form_attachments'));
cart.setVariable(item, 'u_is_file_hosting', producer.getValue('is_file_hosting'));



var request = cart.placeOrder();
//var req_sys_id = request.getValue('sys_id');
var URL = gs.getProperty('glide.servlet.uri') + 'com.glideapp.servicecatalog_checkout_view_v2.do?v=1&sysparm_sys_id=' + request.getValue('sys_id') + '&sysparm_new_request=true&sysparm_view=ess&sysparm_catalog_view=catalog_default';
gs.info('kedar' + request.getValue('sys_id'));
producer.setRedirectURL(URL);
// var si = new redirecttorequestpage();
// var si_result = si.build_url(request.getValue('sys_id'));
// si.final_url(si_result);
// gs.info('kedar' + si_result);
// producer.redirect = 'https://ciscodev.service-now.com/navpage.do';

 

AnimeshP_96
Tera Guru

Hey @KedarB 
I was just looking into the question you posted, 

Firstly record producer is a catalog where it creates a record in backend (database), it will not show the order page
for e.g "Create incident" is a record producer,  it doesn't requires any script to redirect , its inbuilt.

As far as catalog item is concerned, when you submit a item, it redirects first to order page where you can the item details and cart layout details such as price ,quantity etc.

 


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh

Hi Animesh, thanks a lot for the info,

however, I am triggering a request using CartAPI() script in the record producer script window. So is there any way I could write a redirect statement in the script or anything that could be done using catalog client script?

Thanks,

Kedar.

current.setAbortAction(true);
var id = GlideGuid.generate(null);
var caspr_id = gs.getProperty('cisco.caspr.ba.cat.sysid');
var cart = new Cart(id);
var item = cart.addItem(caspr_id);

// Mapping Basic Information Section fields to catalog item fields
cart.setVariable(item, 'name', producer.getValue('name'));
cart.setVariable(item, 'u_service_offering', producer.getValue('u_service_offering'));
cart.setVariable(item, 'u_responsibility_manager', producer.getValue('u_responsibility_manager'));
cart.setVariable(item, 'short_description', producer.getValue('short_description'));
cart.setVariable(item, 'u_business_impact_justification', producer.getValue('u_business_impact_justification'));
cart.setVariable(item, 'install_type', producer.getValue('install_type'));
cart.setVariable(item, 'u_caspr_administration', producer.getValue('u_caspr_administration'));
cart.setVariable(item, 'architecture_type', producer.getValue('architecture_type'));
cart.setVariable(item, 'u_cisco_change_alias', producer.getValue('u_cisco_change_alias'));
cart.setVariable(item, 'use_case', producer.getValue('use_case'));
cart.setVariable(item, 'application_type', producer.getValue('application_type'));
cart.setVariable(item, 'url', producer.getValue('url'));

// Mapping Support and Vendor Information Section fields to catalog item fields
cart.setVariable(item, 'support_manager', producer.getValue('u_support_manager'));
cart.setVariable(item, 'u_support_group', producer.getValue('support_group'));
cart.setVariable(item, 'duty_pager', producer.getValue('u_duty_pager'));
cart.setVariable(item, 'u_business_criticality', producer.getValue('business_criticality'));
cart.setVariable(item, 'u_iaas_provider', producer.getValue('iaas_provider'));
cart.setVariable(item, 'csp_type', producer.getValue('u_caspr_csp_type'));
cart.setVariable(item, 'u_estimated_users', producer.getValue('estimated_users'));
cart.setVariable(item, 'u_user_locations', producer.getValue('user_locations'));
cart.setVariable(item, 'u_french_language_supported', producer.getValue('french_language_supported'));
cart.setVariable(item, 'u_vendor_type', producer.getValue('vendor_type'));
cart.setVariable(item, 'u_new_name', producer.getValue('new_name'));
cart.setVariable(item, 'u_corp_address', producer.getValue('corp_address'));
cart.setVariable(item, 'u_vendor_website', producer.getValue('vendor_website'));
cart.setVariable(item, 'u_duns_number', producer.getValue('duns_number'));
cart.setVariable(item, 'u_vendor_primary_conctact', producer.getValue('vendor_primary_conctact'));
cart.setVariable(item, 'u_vendor_conctact_email', producer.getValue('vendor_conctact_email'));
cart.setVariable(item, 'u_vendor_conctact_role', producer.getValue('vendor_conctact_role'));
cart.setVariable(item, 'u_vendor', producer.getDisplayValue('vendor'));
cart.setVariable(item, 'u_product', producer.getValue('product'));
cart.setVariable(item, 'u_vendor_headquarters', producer.getValue('vendor_headquarters'));
cart.setVariable(item, 'u_vendor_relies_on_third_party', producer.getValue('vendor_relies_on_third_party'));

// Mapping Data Privacy, Protection and Compliance Section fields to catalog item fields
cart.setVariable(item, 'u_data_categories', producer.getValue('data_categories'));
cart.setVariable(item, 'u_data_classification', producer.getValue('data_classification'));
cart.setVariable(item, 'u_pii_categories_of_data_processed_by_vendor', producer.getValue('pii_categories_of_data_processed_by_vendor'));
cart.setVariable(item, 'u_pii_category_level', producer.getValue('pii_category_level'));
cart.setVariable(item, 'u_regulations', producer.getValue('u_regulations'));
cart.setVariable(item, 'u_record_category_and_retention', producer.getValue('record_category_and_retention'));
cart.setVariable(item, 'in_sox_scope', producer.getValue('u_in_sox_scope'));
cart.setVariable(item, 'u_external_privacy_certifications_obtained', producer.getValue('external_privacy_certifications_obtained'));
cart.setVariable(item, 'u_bcr_countries', producer.getValue('bcr_countries'));
cart.setVariable(item, 'u_certs_applied_to_product_or_services', producer.getValue('certs_applied_to_product_or_services'));
cart.setVariable(item, 'u_estimated_number_of_data_subjects', producer.getValue('estimated_number_of_data_subjects'));
cart.setVariable(item, 'u_estimated_users_third_section', producer.getValue('estimated_users_third_section'));
cart.setVariable(item, 'u_where_data_resides', producer.getValue('where_data_resides'));
cart.setVariable(item, 'u_is_data_a_cisco_business_record', producer.getValue('is_data_a_cisco_business_record'));
cart.setVariable(item, 'u_data_deleted_after', producer.getValue('data_deleted_after'));
cart.setVariable(item, 'u_users_create_content', producer.getValue('users_create_content'));
cart.setVariable(item, 'u_system_integration', producer.getValue('system_integration'));
cart.setVariable(item, 'u_free_form_attachments', producer.getValue('free_form_attachments'));
cart.setVariable(item, 'u_is_file_hosting', producer.getValue('is_file_hosting'));



var request = cart.placeOrder();
//var req_sys_id = request.getValue('sys_id');
var URL = gs.getProperty('glide.servlet.uri') + 'com.glideapp.servicecatalog_checkout_view_v2.do?v=1&sysparm_sys_id=' + request.getValue('sys_id') + '&sysparm_new_request=true&sysparm_view=ess&sysparm_catalog_view=catalog_default';
gs.info('kedar' + request.getValue('sys_id'));
producer.redirect = URL;
// var si = new redirecttorequestpage();
// var si_result = si.build_url(request.getValue('sys_id'));
// si.final_url(si_result);
// gs.info('kedar' + si_result);
// producer.redirect = 'https://ciscodev.service-now.com/navpage.do';