The Zurich release has arrived! Interested in new features and functionalities? Click here for more

The value of True/false field

sonita
Giga Guru

In my table I have a field called u_active and the type is True/False.

In my record producer I have a drop down field the values of Add and Delete.

When a record is submitted with 'Add' flag the u_active field should be shown as true; and when a record is submitted with 'delete' flag the u_active field should be shown as false.

(we will keep the deleted records in the database as well)

I have set the default value of the u_active field as true in the dictionary.

in the script section of my record producer I have this code:

if(producer.Add_Delete=="Add")

rec.u_active='true';

if(producer.Add_Delete=="Delete")

rec.u_active='false';

            rec.update();

} else{

rec.initialize();

            rec.u_src_grp_no = group_ids[x];

            rec.u_cid = producer.u_cid;

            rec.u_renewal_month = producer.u_renewal_month;    

rec.u_ctb_prgm_start_dt=producer.u_ctb_prgm_start_dt;

    rec.u_ctb_prgm_end_dt=producer.u_ctb_prgm_end_dt;

rec.u_req_type=producer.Add_Delete;

            rec.insert();

But it does not work!!!!!!!!!!!!! it always shows True. Any help would be greatly appreciated.

24 REPLIES 24

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would try something like this and then check the logs to see what is happening.



                     


                      gs.log('Add_Delete value: ' + producer.Add_Delete, 'RPDebug');


                      if (producer.Add_Delete == "Add") {


                              rec.u_active = 'true';


                              gs.log('Add_Delete: Add', 'RPDebug');


                      }


                      if (producer.Add_Delete == "Delete") {


                              rec.u_active = 'false';


                              gs.log('Add_Delete: Delete', 'RPDebug');


                      }


                      rec.update();



https://instance.service-now.com/syslog_list.do?sysparm_query=source%3DRPDebug


Still not working



find_real_file.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

What do the logs tell you?


it's very slow. i'm still waiting


Brad Tilton
ServiceNow Employee
ServiceNow Employee

If the record has already been udpated and the logs don't show up, then you're not getting to that point in the code. Looking at your code it looks like this is only going to be applicablewhen your record producer is updating an existing record and that checkbox will always be true for new records. Are you testing where your record producer is updating existing records or creating new records?