on 07-14-2018 9:53 AM
Hi experts,
I am trying to persist the last successful run date of an interface in a data store to be used for the next run.
However, how can I do this?
Do I 'write variable' or do I 'Data Store -> Write'?
Also, how can I get this value and output it in content modifier or use it in channels?
edit: also, how can I persist a value that I computed in a groovy script?
I have developed the iflow as follows
writevariable-->Content modifier-->Now I need script(
as we can't directly manipulate the date in channel, instead we have to do the manipulation in script and save that date into a property or header and later use it in communication channel).Please help me on this
Regards
Giridhar Vegi.
Hello Giridhar,
Adding to Morten's reply below is the script which works fine ( not added much validation ) with small building blocks.
def Message processData(Message message) {
def pMap = message.getProperties();
DateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
//Pull the data stored in Write Variable as Property
def lastRunDate = pMap.get("P_LastRunDate");
StringBuffer stb_lastRunDate = new StringBuffer();
//Form the Filter part of your SF query
stb_lastRunDate.append("effective_end_date = to_date('" + lastRunDate + "') ");
def val = stb_lastRunDate.toString();
// Append the QueryFilter in your communication channel query details
message.setProperty("QueryFilter",val);
return message;
}
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Santosh
Regarding variables vs data stores, variables are for single values, whereas data stores are for storing complete messages. So a variable is definitely the right choice for you.
As far as I'm aware, you cannot access variables in a script. You can, however, use a Content Modifier step to store the variable's value in a property, which you can then access in a script. Specifically, create a property of type "Local Variable" (or "Global Variable", as appropriate), like this:
In your script, you can now access the variable's value as follows:
def varValue = message.getProperty('VariableProperty')
The reverse is also possible, i.e. setting a property in a script, and then creating a variable based on that property in the Write Variables step. To do that, create a variable of type "Property", and enter the name of the property in the "Value" field, like this:
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.