update field based on another field on same table

Averyy
Tera Contributor

Hello,

 

I am looking to create a BR between these two fields

Fields

1. Office

2. previous office "previous_office"

 

When the field office changes, I want the field "previous office" to show what was within the offive field before changing. This is my current BR but it is not working.

 

When: before

active: (X)

advanced: (X)

Insert:  Update: (X)  Delete:  Query:

Filter changes: office "changes"

 

Script:

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

    // Add your code here
if (current.office.changes())
{ //Copy the current "office" field to the "previous office" field"
current.previous_office = previous.office;}}
)(current, previous);

 

 

 

 

 

 

1 REPLY 1

Harsh Vardhan
Giga Patron

@Averyy  Script looks ok to me, can you double check the column name is correct in your script? Both fields are string type field ?

I would suggest add logs to check what values are coming based on that you can identify the issue .

 

Thanks,

Harsh