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

Change state of hardware equipment where configuration item is updated

Ahmet1
Tera Expert

Table: alm_hardware

 

We import assets that are delivered into stock room as and when necessary to alm_hardware under our designated stockroom with the serial number , state in stock , stockroom = stockroom name. 

 

When intune integration updates these assets with the correct asset name etc. from the serial number, we want the state of these assets to change from "in stock" to "in use"

The intune update will rename the "configuration item" field to the correct asset name.

 

I am trying to get the state to change to "in use" and tried this via Business Rule and Flow Designer which hasn't worked.

The updates are made by "system" when the Intune sync happens using the Intune plugin.

 

Is there a way to make the Intune plugin update the state of these assets when the sync happens or fix my Business rule / Flow designer?

Current BR / FD is not triggering.

 

Business rule tried (also tried before update):

Ahmet1_1-1695046329654.png

 

 

Flow designer tried:

Ahmet1_0-1695046261042.png

 

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

Hi @Ahmet1 

 

If you use a business rule, set it to run "Before". Set Order to a value greater than 100, Set Advanced and use the following script:

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.install_status = 1;	// value for 'In use' choice for state field on alm_hardware table

})(current, previous);

View solution in original post

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Ahmet1 

Is the BR running if the condition is removed? If it is not running even without any condition, the transform script might be not running. 

Thanks,
Anvesh

Bert_c1
Kilo Patron

Hi @Ahmet1,

 

As far as using a business rule, you haven't posted the script logic. (I see "Advanced" is checked.) Also, 'When to run' should be "Before" or you have to use a "current.update()" in the script, which is not 'Best Practice' (don't update the record just written to the database a second time).

Hi, I must of missed that! there was no script logic so I've unchecked it and retried to trigger it by manually syncing our Intune just now and it didn't get triggered again.

Bert_c1
Kilo Patron

Hi @Ahmet1 

 

If you use a business rule, set it to run "Before". Set Order to a value greater than 100, Set Advanced and use the following script:

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.install_status = 1;	// value for 'In use' choice for state field on alm_hardware table

})(current, previous);