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 08:15 AM
you mean here?
if(producer.Add_Delete=="Delete"){
rec.u_active='false';
rec.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:20 AM
Soni,
I believe that you want to pupulate the u_active field on your form depending the value chosen while submitting the form. is that right ?
I also believe that you used a variable set to get this value before submitting, is that right ?
if yes, get rid of the if / else statement from your script and change it by the following :
current.u_active = producer.NameOfTheVariableInOrderGuide; (be aware that this is case sensitive).
Furthermore, values should be the same in variable set and choice list. In other words, make sure that the value of True is 'true' in both variable set and choice list. Same for 'False'
Let me know please if that works r not
Kind regards
ZA
Do not feel shy to mark correct or helpful answer if it helps or is correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:23 AM
one more thing that may also impact the script to be executed correctly :
Please could you put the script producer.redirect = "home.do"; at the end of script ?
Regards,
ZA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:28 AM
I tried that as well . but didn't work!
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];
producer.redirect="home.do";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 08:41 AM
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;
}
}
} 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.insert();
}
gs.addInfoMessage(group_ids[0] + " the first value");
current.u_src_grp_no = producer.group_ids[0];
producer.redirect="home.do";
try this one
Kind regards,
ZA
Do not feel shy to mark correct or helpful answer if it helps or is correct