Hard Code order_by in a cloned data table from instance widget

kemmy1
Tera Guru

I would like to hard code my already cloned widget to order by a field that is a reference field on the data.table

I found this online so I understand where I need to update this, but WHAT do I update data.o to?

 

The line data.o = data.o || $sp.getValue('order_by'); is a JavaScript expression commonly found in ServiceNow Service Portal widgets. It is used to set a value for the order_by property within the data object, which is typically used to pass information between the client-side and server-side scripts of a widget.

 

data.o = <table name>.<field>.<field>?

So it would be the actual name of the table, then the reference field and then the field on the referenced field? x_g_table.actualreferencefieldname.field?

 

1 ACCEPTED SOLUTION

It would be like dot-walking, correct.

 

In a URL, it would be o=caller_id.last_name, for args with an widget:

data.o = 'caller_id.last_name'

View solution in original post

4 REPLIES 4

Kieran Anson
Kilo Patron

Hi @kemmy1 ,

You would use the field name for the table. For example, to order by priority on incident, you would use the field name 'priority'

But what if (in my case), I need to sort on, let's say a field on a reference field of the incident form.  Specifically, a field on the referenced table.  So (just an example) incident.user.email?  so data.o = data.table.user.email?

It would be like dot-walking, correct.

 

In a URL, it would be o=caller_id.last_name, for args with an widget:

data.o = 'caller_id.last_name'

That worked!  Thank  you!