Transform to Add ServicePointCharacteristicSet



I want to add a diffirent ServicePointCharacteristicSet to ServicePoint (via Canonicals)…
I create a Javascript transforms to do that.
When I test the transform function like a Script snippet (Chrome source window) it’s works but NOT on c3 whith canonicals (=> no charcteristics lnked to facilities and no errors in console).

This is my code in Snippet with a simple exemple of facility:

var d = {
servicePointId: "Ribotta_Fancoil_208",
facilityId: "Ribotta_stanza_T01" ,
commodity:"" ,
maxConsumption: 240,
standByConsumption:25 ,
numberOfStep: 3

function transform(details) {
        var caraMaxConsump 		= ServicePointCharacteristicSet.make({name:"maxConsumption", value: details.maxConsumption })
        var caraServiceType 	= ServicePointCharacteristicSet.make({name:"serviceType", value: details.serviceType })
        var caraStandBy 		= ServicePointCharacteristicSet.make({name:"standByConsumption", value: details.standByConsumption })
        var caraNumberOfStep 	= ServicePointCharacteristicSet.make({name:"numberOfStep", value: details.numberOfStep })

  var fac = Facility.get(details.facilityId);

  return ServicePoint.make({
	id : details.servicePointId,
	facility: fac,
	characteristics : [caraMaxConsump, caraServiceType,caraStandBy,caraNumberOfStep]

Are there some issue with scope into the code when i run it in backend ?



Resolved !!
I add a transform file to transform Canonical to ServicePointCharactericSet and i linked it to ServicePoint with parent field like this

var caraMaxConsump 		= ServicePointCharacteristicSet.make({id:details.servicePointId + "_maxConsumption", name:"maxConsumption", value: details.maxConsumption, parent: {id : details.servicePointId}})
1 Like