The CreatorCon Call for Content is officially open! Get started here.

Help with this logic

Maria Quintero
Tera Expert

Hello I joined Servicenow a couple of months ago and I have this task, I have an idea of how to do it but can someone throw some light on this question?

 

The hierarchy among Operational Cost History lines are set according to a weight logic, where “1” is the lowest/lightest

 

Weights “table” will need the following attributes/fields: caused by, start, end, reconciliated to invoice (true/false) // when we open the OperationalCostHistory record we can see the 4 values, depending on which value are in this 4 fields, we can set one, but we would like it to be not hard coded in a script, we don't want it in the Business rule.
therefore, we'll create another table "weight_och" > we'll have 5 fields > caused by, start, end, reconciliated to invoice (true/false) and.... weight, business rule will run and will take into account weight table and will try to find a weight that has the same caused by, same start, same end, same reconciliation that will give X weight in B and we have to copy it to A
business rule will look into start and end dates (changes)


Also: create triggers if a) end date is in the future so when och gets an update or an insert,a dn end date in the future run this calculation
b) if start date is in the future, do this calculation

 

Kind regards.

2 REPLIES 2

Wybren1
Tera Guru

Feels like you should use a "decision table".

It's quite hard to graph on what your are trying to achieve, maybe shed some light on your end goal?
You need a table to calculate a weight or? or do something based on weight?

Further explanation of the task: 

 

I need to have the current operational cost marked with a suitable status and the possibility for a scalable solution to maintain weights ourselves (role dm_task_user for the “configuration” table)

to avoid confusion of the cost history lines

 

A/C:

The hierarchy among Operational Cost History lines are set according to a weight logic, where “1” is the lowest/lightest

 

Yes, I need to create a table that will take into account another table with these values and will try to find a weight that has the same caused by, same start, same reconciliation that will give a X weight in the new table and I'll have to create a logic to copy it to A.

 

Sorry if it's too confusing with this amount of information, here i leave a script where I should get inspired too:

 

(function executeRule(current, previous /*null when async*/) {
    var utils = new RentHistoryUtils();
   
    utils.setWeightPriorityBR(current);
    utils.clearExistingCurrentBR(current);
   
    // clear weight for historic/future rent history
    utils.clearWeight('future');
    utils.clearWeight('historic');
    utils.clearWeight('awaiting');
    utils.clearWeight('replaced');
   
    utils.setNewCurrentBR(current);
})(current, previous);
 
Thanks.