on 04-30-2016 9:18 PM
Dear Experts,
I am facing an issue while trying to convert a string to int and then casting it back to string.
My requirement is - User is providing an input parameter based on column of datatype VARCHAR. So here FiscalMonth = 2016-M05.
Now I am taking left 4 char of this to return 2016 as string. To calculate previous year I converted this to Int and substracted 1. and finally I casted
this to string and storing in calculated variable of data type VARCHAR.
Its showing me following error
I searched this issue on SCN but many of the posts are referring this to typecast using CE function/ I am trying to create a variable on graphical calculation model and need this to dynamically calculate previous year so that I can compare this previous year with transactional date's year (taken 4 chars of year from string of date)
Could you please guide me for its root cause fix.
Thanks & Regards,
Jiten
Hi,
If you are still facing the issue,
You can break the formulas as below, and try in last formula, i know no point in elaborating the formulas but some times it works..
Create Int conversion seperate,
Create String conversion seperate. and Create leftstr seperate formulas, and in final try your desired requirement formula you can consider the (fiscalmonth -1...
I have faced such issue in SP 1.8, but the above way breaking the formula worked for me...
Dont know exact reasons behind it...
Hope it helps.
Cheers..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Florian/Shireesha/Lajwanth - Thank you all for your suggestions. Appreciate it.
@Florian - We can do this by using Year and Month separately but user prefer to see the values in YYYY-MM format while selecting in Input_parameter.
@Shireesha - a. Removing single quote from input parameter throws 'mismatch error between input parameter and it data type'. b. User want to select/enter year-month to calculate specific month's comparision with previous month.
@Lajwanth - Yes, it works by doing separate conversion of Int, String. I used the same as workaround but wanted to know if I was missing something while conversion. As of now I am good to go with you suggestion !
With Regards,
Jiten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jiten,
Yes as Florian said the error messaged can be ignored, meanwhile you try this
1. Remove quotes of input parameter and validate
string(int(leftstr($$ip$$,4))-1)
2. Or any ways as you are calculating on a column's values, why can't you provide the column directly in expression as below
string(int(leftstr("FiscalMonth",4))-1)
Regards,
Shireesha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jiten,
although the validation expression functionality reports that error, the expression is working. Can you ignore the message, activate your view and test it.
Of course you will still get a "runtime" error if the first four characters cannot be converted to an integer. Is it an option for you to split the parameter into two parameters (one for the fiscal year and one for the fiscal month, typed to the right types to be type safe)?
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
26 | |
10 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.