Record Producer portal redirect not working on custom task-extended table


Description

The portal redirect code/instructions from here is not working for a custom table extended from Task:
https://docs.servicenow.com/csh?topicname=c_PopulatingRecordData.html&version=latest
No matter what URL is used in the Record Producer code, the system directs to the default "ticket" form in the portal upon Record Producer submission.

Resolution

This is an expected OOB behaviour for any Record Producers after submit as the sys_id isn't available yet to process the redirect.

The issue was with the below redirect code on Record Producer script section:
producer.portal_redirect = "?id=form&table=u_event_request&sys_id=" + current.sys_id;

current.sys_id is not available for the script to redirect, hence it will fail and redirect to 'generate task record'.


However, the below workaround can be applied:
1) Clone the OOB 'SC Catalog Item' widget
Copy of SC Catalog Item
widget-sc-cat-item-v2-copy

2) On the Client Script section, modify the below 'handleRedirect' function:
function handleRedirect(n, table, sys_id, redirectTo, redirectUrl) {
var page = 'form';
if (table == 'sc_request')
page = 'sc_request';
else if (table == 'u_custom_table')
page = 'form';
else if (n && table != 'u_custom_table')
page = 'ticket';

3) Add an extra condition to handle redirect for 'u_custom_table' table and set the page to 'form'.