- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2017 02:48 PM
Here my script:
but not working it..
Business rule: table :incident
var totalA = 0;
totalA += current.u_used_amount;
var bRec = new GlideRecord('u-details');
bRec.query();
if(bRec.next()){
bRec.u_reaming_balance = totalA;
bRec.update();
}
8000+5000+3000=16000 , display result sum in u_details table
Table: u_details
Field: u_remaing_balance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2017 03:34 PM
Hi Srivastav,
(function executeRule(current, previous /*null when async*/) {
var cal = 0;
var gr = new GlideRecord('incident');
gr.addQuery('category', 'software'); // is it mandatory ??
gr.query();
while(gr.next())
cal = parseInt(cal) + parseInt(gr.u_used_amount);
var bRec = new GlideRecord('u_details');
bRec.addQuery('fieldname', 'pass the filter value here'); //if it is new table of field then the field is empty , WHAT DO NOW
bRec.query();,
if(bRec.next()){
bRec.u_reaming_balance = cal;
bRec.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2017 04:26 PM
Hi Kishore,
I thought my answer would be correct. 😉
anyways hope you query is solved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 01:52 AM
Hi Srivastav,
i am requesting some modification in script here , please
Business Rule:
(function executeRule(current, previous /*null when async*/) {
var cal = 0;
var gr = new GlideRecord('incident');
gr.addQuery('category', 'software'); // ihere i as it mandatory ??
gr.query();
while(gr.next())
cal = parseInt(cal) + parseInt(gr.u_used_amount);
var bRec = new GlideRecord('sales_lead');
bRec.addQuery('fieldname', 'pass the filter value here'); //if it is new table of field then the field is empty , WHAT DO NOW
bRec.query();,
if(bRec.next()){
bRec.u_reaming_balance = cal;
bRec.update();
}
})(current, previous);
here i have reference field in incident table with name portfolio values in reference table values are FY17 SECURITY,FY17SOFTWARE,FY17 CORPORAYTE
var gr = new GlideRecord('incident');
gr.addQuery('category', 'software'); //HOW CAN I MENTION QUERY HERE
gr.query();
Field in incident table is : Protfolio(reference field , referencce table:portfolio)
SALES_LEADS -Table
Fields name: u_fund_account_name
var bRec = new GlideRecord('sales_lead');
bRec.addQuery('fieldname', 'pass the filter value here'); //if it is new table of field then the field is empty , WHAT DO NOW
bRec.query();,
if(bRec.next()){
bRec.u_reaming_balance = cal;
bRec.update();
}
so how can i give values here in query condition , can you please suggest me here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 02:54 PM
Please if this helps.
1.
var gr = new GlideRecord('incident');
gr.addQuery('u_portfolio', current.u_portfolio);
gr.query();
2.
var bRec = new GlideRecord('sales_lead');
bRec.addQuery('sys_id', 'pass the sys_id here'); //You need to check how can you pass the sys_id dynamically, is there any relation between incident and sales_lead table.
bRec.query();,
if(bRec.next()){
bRec.u_reaming_balance = cal;
bRec.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2017 03:03 AM
Hi Shishir Srivastava,
Here we don't have any relation between incident table and sales table ... ..
And can you please explain
addQuery(); in incident table and sales table how it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 12:01 PM
Hi ,
yes, we had relation in this table.
i have 2 tables sales, and incident
in incident table - fields are there
1.u_Portfolio(reference field - reference table is Sales table values u_sales_dept)
2.u_used_amount
sales - fields
u_sales_dept
u_total_budget (currency field)
u_reaming_budget(currency field)
so now u_reaming_budget = u_total_budget - u_used_amount