The CreatorCon Call for Content is officially open! Get started here.

Query question

amatthews
Kilo Explorer

I   am trying to pull back the records of a particular field in a table.   The query is done on the catalog task so I have to glide to the table where the records reside.   Can anyone tell me the best way to do this?   I have tried the following but not sure it is working:

var xx = new GlideRecord('table');

xx.addQuery('u_requested_item', g_form.getValue('sys_id');

xx.addQuery('fieldname');

xx.query();

while (xx.next()) {

                                                if (fieldname != '' && fieldname != null && action != 'close_task') {

                                                          alert(message);

                                                          return false;

At this point I receive the alert but the task will still close.   I want to prevent the task from closing until the 'fieldname' has been populated.   Any feedback is greatly appreciated.

7 REPLIES 7

Hi,



There are two ways to do this.


You have to apply some BR on the "embedded list" table so that the fields will be mandatory


The other way is to have BR on the current form(with some condition on primary key defined between two tables) and abort the record if the condition is not satisfied.



Thanks,


Pradeep Sharma


Hi,


Thanks again for you feedback.   One more question.   Do I create this BR on my table or the sc_task table?


justin_drysdale
Mega Guru

The 2nd line of your script is missing the closing parenthesis:


xx.addQuery('u_requested_item', g_form.getValue('sys_id');


should be:


xx.addQuery('u_requested_item', g_form.getValue('sys_id'));



Also you have to set a condition to return true.