
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nested If else condition
Hi ,
Am I good with this below nested if else condition?If I am missed any thing let me know the suggestions.
If ([VAR ETO]='ETO'
Then
If [Transfer of Requirem]<>'#' Or [Suspension - Text]<>'Not assigned'
Then '5. Suspended'
ElseIf Today()- RDDate = 0
Then '2. Due Current Month'
ElseIf [Undelivered Quantity] > 0 And RDD < Today()
Then '1.OVD'
ElseIf [VAR YearMonth GID Of RDD]=[VAR YearMonth Current Date]
Then '2. Due Current Month'
ElseIf [VAR YearMonth Current Date]<>[VAR YearMonth GID Of RDD]
Then '3. Due Later'
Else [Undelivered Quantity]<=0
Then '4. Delivered'
)
ElseIF([Item category]='ZSPK' or 'ZSK1'
Then
If [Transfer of Requirem]<>'#' Or [Suspension - Text]<>'Not assigned'
Then '5. Suspended'
ElseIf Today()-RDD = 0
Then '2. Due Current Month'
ElseIf [Undelivered Quantity]>0 And [Sales Order line RDD]< Today()
Then '1.OVD'
ElseIf [VAR YearMonth GID Of RDD]=[VAR YearMonth Current Date]
Then '2. Due Current Month'
ElseIf [VAR YearMonth Current Date]<>[VAR YearMonth GID Of RDD]
Then '3. Due Later'
Else [Undelivered Quantity]<=0
Then '4. Delivered'
)
Else
(
If [Transfer of Requirem]<>'#' Or [Suspension - Text]<>'Not assigned'
Then '5. Suspended'
ElseIf Today()-[GID of RDD]=0
Then '2. Due Current Month'
ElseIf [Undelivered Quantity] > 0 And [GID of RDD]< Today()
then '1.OVD'
ElseIf [VAR YearMonth RDD]=[VAR YearMonth Current Date]
Then '2. Due Current Month'
ElseIf [VAR YearMonth Current Date]<>[VAR YearMonth RDD]
Then '3. Due Later'
Else [Undelivered Quantity]<=0
Then '4. Delivered
)
End IF
Thanks
,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am facing some script error.. Can any one suggest me?

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The syntax of nested If() is
If(condition, If(Condtion, TrueValue, FalseValue), If(Condtion, TrueValue, FalseValue))
Your expression should be like this
If ([VAR ETO]='ETO',
If [Transfer of Requirem]<>'#' Or [Suspension - Text]<>'Not assigned', '5. Suspended',
If (Today()- RDDate = 0, '2. Due Current Month',
If( [Undelivered Quantity] > 0 And RDD < Today(), '1.OVD',
If( [VAR YearMonth GID Of RDD]=[VAR YearMonth Current Date], '2. Due Current Month',
If( [VAR YearMonth Current Date]<>[VAR YearMonth GID Of RDD], '3. Due Later',
If([Undelivered Quantity]<=0, '4. Delivered')))))))
Regards,
Jagan.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you writing it in script or in expression?????

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanku jagan,
I am trying to write it in script level.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not completely follow on the intention of your script. My first suggestion is that you simplify the script, by shortening it to a minimum of IF-ELSEIF so that you can validate your principle to work before completing the entire script.
When I paste your script in the script editor the entire script is underlined in red, which means you have a major error in the way the syntax is written.
In the script the proper IF statement is written as the manual dictates. From this you can see that the IF / ELSEIF and THEN should remain on the same line. The big breaking point in your structure is how ever that IF can not be followed by ELSEIF as you enforce due to the brackets you have used in for example line 1 and 15.
IF condition THEN
[ statements ]
{ ELSEIF condition THEN
[ statements ] }
[ ELSE
[ statements ] ]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even in the load script you can have two different types of IFs. Let me summarize what the others are pointing out.
- IF function
This one really is a function that produces a single result. It comes with 2 or 3 parameters. The syntax is like the one Jagan mentioned:
IF (condition, then_expression)
or
IF (condition, then_expression, else_expression)
You can use this wherever an expression van be specified, such as in a LET statement, a column assignment in a LOAD statement etc. You can NOT use this a the outer level of your script or as a stand-alone statement. - IF control statement
This one does not produce a single value, but triggers the execution of a specific code block (or just skips the execution). This is a regular IF statement. The syntax is like the one Toni mentioned:
IF condition THEN
code block
ELSIF condition
code block
ELSE
code block
END IF
Almost everything is optional, except the initial IF line and the END IF terminator. You can use this type of IF wherever a script statement is expected, but NOT for example in an expression or inside a LOAD statement.
The example in your original post mixes the two formats.
If this still isn't entirely clear, ask away.
Peter
