- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2024 08:23 AM - edited ‎03-14-2024 08:24 AM
I have cloned the "SC ORDER STATUS" Widget because I need to add a custom button for every opened RITM. The button should not appear when the RITM's state is "closed complete". However, the condition to show the button in my HTML code doesn't seem to be working, and I'm not sure why. Below is the code. Thanks in advance.
<td>
<div class="panel-body" >
<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('resolve', requestItem.sys_id)" ng-if="c.requestItem.state !='3'">Conferma Acquisto</button>
</div> </td>
CLIENT SCRIPT
function test() {
c.uiAction = function(action,myRitm) {
c.data.action = action;
c.data.ritm = myRitm;
alert(action);
alert(myRitm)
c.server.update().then(function(test) {
c.data.action = undefined;
})
}
}
SERVER SCRIPT
(function(test) {
// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");
gs.log("MIAO MIAO data.table " + data.table);
if (data.table == 'sc_request') {
gr = new GlideRecord(data.table);
// Valid GlideRecord
gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
// Valid sys_id
if (!gr.get(data.sys_id))
return;
gs.log("miao miao miao SYSID" + data.request.requestItems);
var grReqItem = new GlideRecord("sc_req_item");
grReqItem.addQuery('request', gr.sys_id);
grReqItem.addQuery('sys_id',input.ritm)
gs.log("MIAO MIAO MIAO QUERY SC REQ ITEM" + grReqItem.addQuery('request', gr.sys_id));
grReqItem.query();
var action = input.action;
gs.log("MIAO MIAO action" + action + " test " + input.ritm);
if(grReqItem.next()){
gs.log(("grReqItem.next() " + grReqItem.getRowCount()));
gs.log(("grReqItem.next() " + grReqItem.getRowCount() + "" + grReqItem.number));
grReqItem.setValue('state', 3);
grReqItem.update();
}
if (action == 'resolve') {
gs.log("MIAO MIAO MIAO ALL INTERNO DELL ACTION RESOLVE")
grReqItem.setValue('state', 3);
grReqItem.setValue('stage', 'fulfillment');
grReqItem.update();
}
}
})();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 02:10 AM
I have resolved the issued, just adding in oob code the state "steatment". Thx for ur support.
data.request.requestItems.push({
sys_id: reqItemGr.sys_id.getValue(),
name: catItem.name,
delivery_date: ritm.getDeliveryDueDate(),
stage: reqItemGr.stage.getValue(),
state:reqItemGr.state.getValue(), //custom <---------HERE I RETRIEVE THE STATE
number: reqItemGr.number.getValue(),
quantity: reqItemGr.quantity.getValue(),
show_quantity: catItem.show_quantity,
show_delivery_time: catItem.show_delivery_time,
price: parseFloat(reqItemGr.price.getValue()),
price_dv: reqItemGr.price.getDisplayValue(),
recurring_price: parseFloat(reqItemGr.recurring_price.getValue()),
recurring_price_dv: reqItemGr.recurring_price.getDisplayValue() + ' ' + frequency_dv,
requested_for: reqItemGr.getDisplayValue("requested_for"),
requested_for_id: reqItemGr.getValue("requested_for"),
showPrice: showItemPrice,
showRecurringPrice: showItemRecurringPrice,
total_price: itemTotalPrice,
total_price_dv: spCurrencyFormatter.format(itemTotalPrice),
total_reccuring_price: itemTotalRecurringPrice,
total_reccuring_price_dv: spCurrencyFormatter.format(itemTotalRecurringPrice) + ' ' + frequency_dv,
stageWidget : $sp.getWidget("cb6631d39f2003002899d4b4232e7030", {req_item_id: reqItemGr.sys_id.getValue(), onload_expand_request_item_stages: false})
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2024 10:23 AM
I believe 2 colons is a "::" is a one way binding and not a two way binding which could be the cause. If its on the requested item and you are watching the requested item, the record watcher solution should work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2024 02:10 AM
I have resolved the issued, just adding in oob code the state "steatment". Thx for ur support.
data.request.requestItems.push({
sys_id: reqItemGr.sys_id.getValue(),
name: catItem.name,
delivery_date: ritm.getDeliveryDueDate(),
stage: reqItemGr.stage.getValue(),
state:reqItemGr.state.getValue(), //custom <---------HERE I RETRIEVE THE STATE
number: reqItemGr.number.getValue(),
quantity: reqItemGr.quantity.getValue(),
show_quantity: catItem.show_quantity,
show_delivery_time: catItem.show_delivery_time,
price: parseFloat(reqItemGr.price.getValue()),
price_dv: reqItemGr.price.getDisplayValue(),
recurring_price: parseFloat(reqItemGr.recurring_price.getValue()),
recurring_price_dv: reqItemGr.recurring_price.getDisplayValue() + ' ' + frequency_dv,
requested_for: reqItemGr.getDisplayValue("requested_for"),
requested_for_id: reqItemGr.getValue("requested_for"),
showPrice: showItemPrice,
showRecurringPrice: showItemRecurringPrice,
total_price: itemTotalPrice,
total_price_dv: spCurrencyFormatter.format(itemTotalPrice),
total_reccuring_price: itemTotalRecurringPrice,
total_reccuring_price_dv: spCurrencyFormatter.format(itemTotalRecurringPrice) + ' ' + frequency_dv,
stageWidget : $sp.getWidget("cb6631d39f2003002899d4b4232e7030", {req_item_id: reqItemGr.sys_id.getValue(), onload_expand_request_item_stages: false})
});
}