cancel
Showing results for 
Search instead for 
Did you mean: 

Write Variable is not working

huibin_lau
Participant
0 Kudos

Hi Integration Experts,

I have a delta sync scenario which I need to use a write variable to keep the last run date time in this format yyyyMMddHHmmss and retrieve it in the next run. In the content modifier I have defined a field ShipDate and it was filled during runtime. I also defined a write variable based on the field I created earlier but the value was not written. Any idea what is wrong?

Best Regards,

Jeremy

Accepted Solutions (1)

Accepted Solutions (1)

ashish_goel4
Active Participant
0 Kudos

Hi Jeremy,

Try displaying/checking the value of ShipDate if it is setting at runtime to the property properly. You can try it giving constant value in property.

Also, In write variable , check the box Global scope if it helps. Here also, you can try with current date and time.

capture1.jpg

Thanks,

Ashish

huibin_lau
Participant
0 Kudos

Hi Ashish

Try displaying/checking the value of ShipDate if it is setting at runtime to the property properly.

>I logged the value of ShipDate and it was passed correctly at runtime.

Also, In write variable , check the box Global scope if it helps. Here also, you can try with current date and time.

>If I use the current date and time then it works. However my requirement is to use the computed date and time based on the response but then the write variable does not work anymore.

Regards,

Jeremy


ashish_goel4
Active Participant

In that case, try with Xpath expression in write variable.

I used xslt to remove namespace from XML so xpath can be parsed. No need to set in property. For me it worked.

huibin_lau
Participant
0 Kudos

Thanks Ashish,

It works by using xpath. In principle it should work with property and header fields as well because it worked if I used the current date time but it is not the case. Anyway my problem is solved.

Have a nice day!

Best Regards,

Jeremy

Answers (2)

Answers (2)

0 Kudos

Hi Jeremy,

Please find attached following changes.

this should help!

thanks and regards,

Praveen T

huibin_lau
Participant
0 Kudos

Hello Praveen,

I tried what you suggested but the problem is not solved. I am using a script to update the property.ShipDate and the value can be kept but when using write variable with the same field it is not working unfortunately.

Regards,

Hui Bin

0 Kudos

Hi Jeremy,

Is it possible to share the i-flow with us.

would need to check in which order are you writing in the script.

Alternatively you could write the property value in the datastore/log and check if the value is set before writing on to the write-variable.

thanks and regards,

Praveen T

huibin_lau
Participant
0 Kudos

Hi Praveen,

Sure. The iflow looks like this. Content Modifier 9 is the response

In the content modifier 7 I defined the property field "Shipdate"

In the script I update the property field "ShipDate" based on the ship date in the response like this format 201801010000.

Lastly, I write the variable as mentioned earlier above but nothing is written.

Regards,

Jeremy

0 Kudos

Hello Jeremy,

Please use below code in the script to check if there any value present in the property.

def map = message.getProperties();
def ShipDate= map.get("ShipDate")
def messageLog = messageLogFactory.getMessageLog(message)
if (messageLog != null) {
  messageLog.setStringProperty("ShipDate", ShipDate);
}

thanks and regards,

Praveen T

huibin_lau
Participant
0 Kudos

Thanks Praveen,

The problem is already solved by using xpath.

Regards,

Jeremy

huibin_lau
Participant
0 Kudos

Hi sriprasadshivaramabhat,

You are always welcomed. 🙂

Thanks,

Jeremy