Related list action to open a new form

MaharshiC
Tera Contributor

Hi,

 

 

I have a request table and request_item table. The request_item table is coming as a related list in the workspace. I want to create a related list action is the request_item table called upload and when i click on that it will basically redirect to a new form where the request number  from the request table will get auto populated in the new form and there will be an attachment field which will need to be mandatory. Can somebody please provide the  script to do this? 

1 ACCEPTED SOLUTION

@MaharshiC 

try this

function onClick() {
var url = 'https://emcitizendev.service-now.com/x/iem/tqa-workspace/record/x_iem_tqa_work_request/cf0f63f31b6f96103df95314604bcbb9/params/selected-tab-index/1/sub/record/x_iem_tqa_work_request_items/-1_uid_1/params/query/work_request_number%3Dcf0f63f31b6f96103df95314604bcbb9/extra-params/query%2Fwork_request_number%3Dcf0f63f31b6f96103df95314604bcbb9%2FparentTable%2Fx_iem_tqa_work_request%2FparentRecordSysId%2Fcf0f63f31b6f96103df95314604bcbb9';
open(url, '_blank');
 }

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@MaharshiC 

did you check any OOB Related list actions?

AnkurBawiskar_0-1739886175969.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@MaharshiC 

this link will help you to create a new one

How to add records in a related list with UI builder (declarative action) 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

This is the the related list action I have created .

MaharshiC_0-1739890371973.png

 

 

function onClick() {
var num = g_form.getValue('work_request_number');
var instanceName = g_form.getValue('instance_name');	
var url='https://emcitizendev.service-now.com/x/iem/tqa-workspace/record/x_iem_tqa_work_request/'+num+'/params/selected-tab-index/1/sub/record/x_iem_tqa_work_request_items/-1_uid_5/params/query/work_request_number%3Dcf0f63f31b6f96103df95314604bcbb9/extra-params/query%2Fwork_request_number%3Dcf0f63f31b6f96103df95314604bcbb9%2FparentTable%2Fx_iem_tqa_work_request%2FparentRecordSysId%2Fcf0f63f31b6f96103df95314604bcbb9';
var win = top.window.open(url, '_self');
	win.focus();
 }

 

 

The work request number  (var num = g_form.getValue('work_request_number');) is not returning anything over here. Actually this is a reference field in the item table to the request table. Is it possible to get the value before the item is created

@MaharshiC 

try this

function onClick() {
var url = 'https://emcitizendev.service-now.com/x/iem/tqa-workspace/record/x_iem_tqa_work_request/cf0f63f31b6f96103df95314604bcbb9/params/selected-tab-index/1/sub/record/x_iem_tqa_work_request_items/-1_uid_1/params/query/work_request_number%3Dcf0f63f31b6f96103df95314604bcbb9/extra-params/query%2Fwork_request_number%3Dcf0f63f31b6f96103df95314604bcbb9%2FparentTable%2Fx_iem_tqa_work_request%2FparentRecordSysId%2Fcf0f63f31b6f96103df95314604bcbb9';
open(url, '_blank');
 }

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

I tried it worked.

 

 

function onClick() {
var num = g_form.getValue('work_request_number');
var instanceName = g_form.getValue('instance_name');	
var url='https://emcitizendev.service-now.com/x/iem/tqa-workspace/record/x_iem_tqa_work_request/'+num+'/params/selected-tab-index/1/sub/record/x_iem_tqa_work_request_items/-1_uid_5/params/query/work_request_number%3Dcf0f63f31b6f96103df95314604bcbb9/extra-params/query%2Fwork_request_number%3Dcf0f63f31b6f96103df95314604bcbb9%2FparentTable%2Fx_iem_tqa_work_request%2FparentRecordSysId%2Fcf0f63f31b6f96103df95314604bcbb9';
open(url, '_blank');
	
 }

 

 

 The work request number  (var num = g_form.getValue('work_request_number');) is not returning anything over here. Actually this is a reference field in the item table to the request table. Is it possible to get the value before the item is created. This is to make the URL dynamic.