Hi All,
As part of the requirement, I have created a rule to convert text fields data into date and time. The rule is working fine on the UI, which executes one row at a time, but when the same rule is used in Process model using a!forEach for converting multiple text fields the data is not getting converted properly.
a!forEach( items: pv!subServiceOrder, /*this is the CDT*/ expression: { if(rule!SOA_checkIsBlank(fv!item.CreatedOn),{}, /*CreatedOn is the field on which time conversion has to happen, it is a text field */ rule!SOA_timeConversion(date:fv!item.CreatedOn,countryCode:fv!item.CountryCode , /* CountryCode is the field which contains the country code, based on which time conversion has to happen */time:fv!item.TimeZone /* TimeZone is the field which contains the country code, on which time conversion to happen */)) })
Attached SOA_timeConversion rule for reference
load( local!count:17, local!a: split(ri!date,"T"), local!date : local!a[1], local!time: local!a[2], local!b: split(local!date,"-"), local!year: local!b[1], local!month: local!b[2], local!day: local!b[3], local!c: split(local!time,":"), local!hour: local!c[1], local!minute: local!c[2], local!second: left(local!c[3],2), local!x: gmt(todatetime(datetime(local!year, local!month, local!day, local!hour, local!minute, local!second))), local!counter: if( and(local!day>=10,local!month>=10),local!count+2, if(or(local!day>=10,local!month>=10),local!count+1,local!count) ), local!datasubset: a!queryEntity( entity: cons!SOA_ISO_COUNTRY_LIST, query: a!query( selection: a!querySelection( columns: { a!queryColumn( field: "isoCountryTimeZone" ), a!queryColumn( field: "dayLightTimeDiff" ), a!queryColumn( field: "observeDST" ) } ), filter: a!queryFilter( field: "isoCountryCode", operator: "in", value: ri!countryCode ), pagingInfo: a!pagingInfo(1,-1) ) ).data, if( and(local!datasubset.observeDST = "1",isindaylightsavingtime(local!x,local!datasubset.isoCountryTimeZone)), left(tostring(local!x+(todecimal(ri!time)/24)+(todecimal(local!datasubset.dayLightTimeDiff)/24)),local!counter), left(tostring(local!x+(todecimal(ri!time)/24)),local!counter) /*substitute(tostring(local!x+timezone)," GMT+00:00","")*/ ) )
Please let me know if there are any changes that are to be made for the rule.
Thanks in advance.
Regards,
Someshwar
Discussion posts and replies are publicly visible