Related List is Loading the sc task very slow.

ashish9
Tera Contributor

I have a record on sc_task form for which I have created a Email Relationship which will show all Emails went for that record where SC Task number is in Subject of Email.

 

It is working fine with below script but it is making Loading very slow even 20 25 seconds.   (Slow In prod because there are a lot of emails we have)

 

What can I can add to load it more quickly.

 

 

Email Relationship Applies to table sc_task

 

Query from Table is -    sys_email

 

 

   var gdt = new GlideDateTime(parent.sys_created_on);
  gdt.addDaysUTC(-1);
      current.addEncodedQuery('sys_created_on<=javascript:gs.endOfToday()');
      current.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate(" + "'" + gdt.getDate() + " 00:00:00" + "'" + ")");
      current.addQuery('type', 'sent');
    current.addQuery('subject', 'CONTAINS', parent.number);

3 REPLIES 3

Mahendra RC
Mega Sage

Hello Ashish, 

You query seems fine but may be due to large number of records in sys_email table it is taking the to get the data to show in related list.

1. On way to reduce the loading time for the sc_task table is that you can set glide.ui.defer_related_lists property to true. So that the related list will load after the form has loaded. But this will be a global change in your instance.

2. Other way to overcome this issue is to remove the related list and instead of showing the data in related list you can create a Ui action to show the button Show related emails on sc_task form. So if the user want to see the sent emails then users can click on the button to see the emails related to the sc_task. In UI action you can write a script to just redirect to new tab with your query on sys_email table. Something like below:

function redirectToCreateKB() {
	var  taskNumber = g_form.getValue("number");
	if (g_scratchpad.task_created_date) {
	var createDate = g_scratchpad.task_created_date;
	var query = "ENTER YOUR QUERY HERE";
	g_navigation.open("/sys_email_list.do?sysparm_query=" + query);
	}

}

Since the Created date is not present on the form so you can either include that on the form or you can use the Display BR to set the g_sratchpad object with created date value and then use the g_scratchpad object value in UI action script:

Display BR script:

g_scratchpad.task_created_date = current.getValue("sys_created_on");

If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful. This will help others with similar issue to find the correct answer.

Thanks

Hello Ashish,

Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.

Thanks

Thanks Mahendra Will try this