Improving performance in property evaluation using settemporary method

The benefit of this method is that only one expression is evaluated for each node but a range of calculated values are returned for multiple properties, and as a result the method explained here:

  • increases performance in datasets where multiple properties contain calculated values
  • allows the reuse of traversals (expressions calculating up and down the tree) without needed to perform these calculations again/rely on dependency order.

The benefit of this approach is that, rather than typing individual expressions directly into the Default Value box for properties to be calculated, OrgVue enables multiple properties to be set via a single expression held either in a specified property or executed via a script.

There are several references to expressions here, which are not covered in detail as the article concentrates on using the settemporary method itself, further reading on expressions can be found in the Gizmo Cookbook

How to use ‘settemporary’ (and ) to evaluate all your properties in one

  • Create a property called “Expressions” (or indeed, any other convenient name)
  • Set the default value of this property as “node.settemporary({ a:x, b:y, …, c:z})” where:

    a, b, c = the names of properties that are going to be populated with calculated values, and
    x, y, z = the expressions to be evaluated

 

  • Set the evaluation type of all the properties evaluated in this way to Script (see Evaluation Mode)
  • The names that need to be listed are the property key values, which must be exactly as they appear in the Edit Property dialogue (hint: either avoid spaces or use underscores in property keys)
  • Within the dedicated settemporary expressions property, click Apply button to execute and evaluate the expression to populate listed property keys
node.settemporary ({
   a: node.format("{department} {country}"),
   b: node.math("currentsalary+currentbonus")
   c: node.rollUp("sum","currentsalary")
})


Troubleshooting

For settemporary to work, all the expressions it contains must be evaluated at the same time. This means it cannot contain any dependencies. If it does, the whole is expression will fail and none of the calculated properties will given their values.


• Circular references are instances where two or more properties are calculated with reference to each other.
e.g. calculating ‘DOB’ as : node.birthday.age() & ‘Birthday’ as : node.dob–node.age will not function correctly because both expressions reference the other
• This leaves a chicken-and-egg scenario that prevents OrgVue calculating either property correctly



The script + ‘settemporary’ method is easy to use


• Create in this way, the default expressions you would usually enter into each property separately can all be combined, and evaluated, as a single property
• The other properties are updated when the settemporary expression is evaluated

node.settemporary ({
    totalannualcompensation: node.math('current_salary + current_bonus + pension'),
    bradfordindex: Math.pow(node.absence_instances,2)* node.absence_days,
    age: node.date_of_birth.age()
})

 Addendum

In practice the scope of settemporary can be much broader than that depicted here: the following expression uses settemporary evaluation in conjunction with linked processes/roles datasets to generate a series of arrays against different node properties in the target for further analysis.

The first line entry is to ensure all the links are retrieved from the target in the first instance, to prevent multiple individual queries subsequently.

var targets = node.alllinks.to;
node.settemporary
({
              Target_Location: targets.location.to_a,
              Target_Role_Grade: targets.gradenumber.to_a,
              Target_Country: targets.country.to_a,
              Target_Business_Area: targets.businessarea.to_a,
              Target_Job_Title: targets.jobtitle.to_a,
              Target_Role_ID: targets.id.to_a,
              Target_Role_Count: targets.count,
              Target_Role_Change_Estimate:  targets.rolechangeestimate.to_a,
              Target_Role_Impact_Type: targets.roleimpacttype.to_a,
              Target_Job_Family_Group: targets.jobfamilygroup.to_a
})

 

 

 

 

 





Have more questions? Submit a request

Comments