How to sort the list like newly created records to display first in widget in portal

Bala13
Kilo Guru

Hi,

Can anyone help me how to display the list of records in a widget to display newly created records first.

We have a widget and in the script i have to write a syntax to display newly created records on the top.

How can i achieve it?

I tried but its not working. Please help me.

 

(function() {
    var tableName = 'u_table';
    var projectId = $sp.getParameter("sysparm_sys_id") || $sp.getParameter("sysparm_projid");
	
    var statusId = $sp.getParameter('sysparm_report_id');
	var topQuery = "top_task="+ projectId + "^u_status=Red^closed_atRELATIVEGT@dayofweek@ago@7^ORclosed_atISEMPTY^u_typeINRisk,Issue";
topQuery.orderByDesc("sys_created_on");  /// I ADDED THIS BUT NOT WORKING
	
  

    data.pending = statusReport.getRisks(topQuery, tableName);

})();
5 REPLIES 5

Community Alums
Not applicable

Hi Bala,

You can opt for simple list widget.

Can you open  sp_instance_vlist.LIST.    This table hold the simple list widget isntance open the record for which you have created a simple list.

 

Bring the Order by field on the from using configure - form layout.

 

Open the list:

find_real_file.png

Search with the table for which you have crated the list.

Open the from: Configure form layout -- bring order by field on the form.

and update the field to which you want the order.

find_real_file.png

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

 

Hi Sandeep,

 

Could you please assist me, where i need to start and how can i acheive this?

This is the report widget, and here the records should display newly created first.

In this case, VS30 short description is created on 11-23-2022 and Due to new record is created in 11-04-2023.

So, we need to display 11-23-2022 as first record. How can i acheive that?

 

find_real_file.png

 

(function() {
    var tableName = 'u_ridac';
    var projectId = $sp.getParameter("sysparm_sys_id") || $sp.getParameter("sysparm_projid");
	
    var statusReportId = $sp.getParameter('sysparm_report_id');
	var topTaskQuery = "top_task="+ projectId + "^u_rag_status=Red^closed_atRELATIVEGT@dayofweek@ago@7^ORclosed_atISEMPTY^u_ridac_typeINRisk,Issue";
topTaskQuery.orderByDesc("sys_created_on");  /// I ADDED THIS BUT NOT WORKING
	
    var statusReport = new PmProjectStatusReport();
    var reportBaselineId = statusReport.getReportBaselineId(statusReportId);

   // if (reportBaselineId) {
   //     tableName = 'risk_baseline';
	//	topTaskQuery = "parent=" + reportBaselineId + "^impact=1^risk_state=1^ORrisk_state=2";
   // }

	

    data.pending_milestones = statusReport.getRisks(topTaskQuery, tableName);

})();

Community Alums
Not applicable

Hi Bala,

This is different question then the original. Kindly mark the answer as Correct & Helpful both and close this thread such that others can get help.

Raise a new question.

Thanks,
Sandeep

sandeep, I have asked the same question. Like in widget how can i display the newly created records first. 

I have attached script and screenshot now.

Please advise me how can i acheive this?