Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Variable error

Hi,

I have created an variable in script but it is showing an script error,but i have tested the same in text object its working fing fine.

Please find the below error.

Variable : let vCurr_Month_Year = month(monthstart(max(ActivityDate-1)))&' '&(year(max(ActivityDate-1)));

Untitled.png

Thanks..

38 Replies
tresesco
MVP
MVP

Yes it would work in the UI but not in the script. Let me explain why. The problem is max() in your expression. You can't use any field using aggregation function in variable declaration in the script like that. They can only be used in a load statement.

You may rather try something like:

Load

          Max(AcivityDate) as MaxDate

From <>;

Let vMaxDate=Num(Peek(MaxDate))-1;

let vCurr_Month_Year = month(monthstart($(vMaxDate))&' '&(year($(vMaxDate)));


Edit: Corrected the field name

Anil_Babu_Samineni

What is your intend to show?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

May be try with SET instead of let:

SET vCurr_Month_Year = month(monthstart(max(ActivityDate-1)))&' '&(year(max(ActivityDate-1)));

gireesh1216
Creator II
Creator II

Hi Naresh,

Activate date is  not use directly in let function.

do one thing

create two variables in front end:

vA1=month(monthstart($(vMax))-1);

vA2= year(date($(vMax)))-1;


Then open text box object use below expression


=vA & vB

It will working fine



Thanks

Gireesh

gireesh1216
Creator II
Creator II

This function also not working...

nareshthavidishetty
Creator III
Creator III
Author

Hi,

I think set wont help.

Thanks..

tresesco
MVP
MVP

I have corrected the field name in the post above. Now give a try.

gireesh1216
Creator II
Creator II

Create three variables in front end using variable overview


vA=month(monthstart($(vMax))-1);

vA= year(date($(vMax)))-1;

vCurr_Month_Year =vA & vB



Then open text box object use below expression


=vCurr_Month_Year

working fine in my system

nareshthavidishetty
Creator III
Creator III
Author

Hi,

What is vMax ?

Thanks..