Update work notes if variable changes

Joe Weisiger
Giga Expert

Hello,

I have an order guide/catalog item that uses a variable set and the variables are cascaded.  If someone changes a variable on an associated task I want to capture the change in the activity stream work note.  How can I accomplish this?

Thanks,

Joe

1 ACCEPTED SOLUTION

@Joe Weisiger 

 

Can you test this once 

var key;
	for(key in current.variables){
			if(current.variables[key] != previous.variables[key]){
				current.work_notes = "Variable changed "+key + "Value Changed to"+current.variables[key];
			}
	}

View solution in original post

16 REPLIES 16

Thanks Joe for pointing it out 🙂

Let us know if you need more help.

 

I fixed the above code.

Joe Weisiger
Giga Expert

Ankur, this worked!  When I change a variable in the task it shows "Variable Changed" in the work notes activity.  

I have a few other questions regarding this.

1)  Is there a way to configure this to all catalog items instead of specifying just 1?

2)  Instead of just recording "Variable Changed" can I give more detail specifying what variable changed and what it changed from and to?

Thanks again for the help!

Hi Joe

 

To make it work for all, don't add this && current.request_item.cat_item.name == 'Catalog Item Name here'

 

To make it work for all variables

 Try something like this 

for(var key in current.variables){
			if(key in previous.variables){
				if(current.variables[key] != previous.variables[key]){	
					current.work_notes = "KA variable"+key+"Change to"+current.variables[key];
				}

			}
		}

 

Regards

Pranav

When I take out this part of the condition " && current.request_item.cat_item.name == 'Catalog Item Name here'" It does work for all catalog items.

 

but when I add the below script it stops working all together.

for(var key in current.variables){
			if(key in previous.variables){
				if(current.variables[key] != previous.variables[key]){	
					current.work_notes = "KA variable"+key+"Change to"+current.variables[key];
				}

			}
		}

@Joe Weisiger 

 

Can you test this once 

var key;
	for(key in current.variables){
			if(current.variables[key] != previous.variables[key]){
				current.work_notes = "Variable changed "+key + "Value Changed to"+current.variables[key];
			}
	}