The value of True/false field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 06:08 AM
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.
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 06:20 AM
You're setting the field correctly in the script. My guess would be that your conditions aren't working. I would validate that the name of your variable is indeed Add_Delete and that the values of your choices are correct. They are case sensitive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 06:27 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 06:32 AM
In that case your syntax is ok. Could you post the whole script? I'm guessing the issue may be there somewhere. You might also add some logging to the RP to check to see if the value is being set and then overwritten somewhere else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 06:35 AM
FYI: I have set the default value as true in dictionary .
producer.redirect="home.do";
current.u_req_type=producer.Add_Delete;
var json = new JSON();
var group_ids = producer.u_src_grp_no+'';
group_ids=group_ids.split(',');
gs.addInfoMessage(json.encode(group_ids));
gs.addInfoMessage(group_ids.length);
if(group_ids.length > 1){
for (var x = 1; x < group_ids.length; x++){
var rec = new GlideRecord('u_ctb');
///First, query to see if there's a record already with the same Client/Group combination
rec.addQuery("u_src_grp_no", group_ids[x]);
rec.addQuery("u_cid", producer.u_cid);
rec.query();
if(rec.next()){
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;
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();
}
}
}
//gs.addInfoMessage(group_ids[0] + " the first value");
current.u_src_grp_no=group_ids[0];