Setting CONSTANT values at destination only during Record Creation and skip for Record Updation.
search cancel

Setting CONSTANT values at destination only during Record Creation and skip for Record Updation.

book

Article ID: 273252

calendar_today

Updated On:

Products

ConnectALL

Issue/Introduction

In automation, when you are willing to pass the _CONSTANT value from the source app to the destination app it will overwrite the destination field with the value passed in constant during every update pushed from the source app.
If you update that value in the destination, it will overwrite the value in the next update from the source. That's how _CONSTANT works.
What if you want to restrict it for updates and let it work just during record creation at the destination app?

Environment

Release : 2.11.2.x

Cause

This is how _CONSTANT functions.

Resolution

Below Business Script can take care of this use case.
The steps outlined in the Article can be followed to set up the Business logic for this use case. Below is the groovy script that can help you achieve this.

Execution Type = POST_MAPVALUE

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.go2group.connectall.config.model.bean.*;

println "Applying Custom Business Rules Constant"

def is_update=message.payload.getRecordLink();

//if(is_update != null)
if(is_update != null && message.payload.getRecordLink().getDestination().getRecordId() != null)
{

// Each of the below 3 lines of code is for one constant that you add in field mapping

	message.payload.deleteField("_CONSTANT");
  	message.payload.deleteField("environment");
  	message.payload.deleteField("environment_CONSTANT");

  	message.payload.deleteField("_CONSTANT");
  	message.payload.deleteField("customfield_10516");
  	message.payload.deleteField("customfield_10516_CONSTANT");
  
	return message.payload
}
return message.payload