How to return a blank value when another value is not returned
Hello,
We are using Siverware for Bartender in BC SaaS and are trying to calculate case quantities which are based on a calculation. What I am trying to do is:
- Pull in the Item Unit of Measure.Code = CS
- If CS does not exist, then I want the Case Qty to show as blank
- If the line's Unit of Measure Code = CS, then print the line Quantity
Right now what is happening, no matter how I write the VB script, if there is no Item Unit of Measure.Code = CS, then the line Quantity is being divided by 0. This is the latest rendition of my VB script, and any help would be GREATLY appreciated!
Value1 = 0
If Format.NamedSubStrings("ItemUnitofMeasure_Code").Value = "CS" Then
Value1 = Format.NamedSubStrings("ItemUnitofMeasure_QtyperUnitofMeasure").Value
End If
Value = IIF(Format.NamedSubStrings("IWXLPLine_UnitofMeasureCode").Value = "CS",Format.NamedSubStrings("IWXLPLine_Quantity").Value,IIF(Value1=0,"",Format.NamedSubStrings("IWXLPLine_Quantity").Value / Value1))
-
Peter Thane
★ BarTender Hero ★
You could add an extra If statement and variable so that if the CS is blank then it uses the new variable that has a value of 1 otherwise it uses the CS value.
Something like
Value2 = 1
If Value1= 0 then
Value2 = Value2 else
Value2 = Value1
endif
and then you final command would instead end Value/Value2
0 -
Greg Zavela
★ BarTender Hero ★
Thank you for the suggestion Peter. However, the issue is if there is no value of CS, then I need the label to not print a value (i.e. leave the value as blank).
0 -
Peter Thane
★ BarTender Hero ★
Change it to this and hopefully that should work for a blank or a value now for CS
Value2 = 1
If Value1= "" then
Value2 = Value2
else Value2 = Value1
end if
0 -
Greg Zavela
★ BarTender Hero ★
Hi Peter,
Thank you for the suggestions! I found the search and replace function under the transforms tab of my named data source. I was able to set Value1 equal to a dummy value that would never be returned if the CS unit of measure does not exist, then I did a search and replace to replace said value with one space which essentially makes the value become blank. One thing I think I have discovered is it appears that the VBScript does not work like Excel where in a nested IF statement once the condition(s) has been met the nested IF statement stops there and returns the values from the true part of the statement.
0 -
Peter Thane
★ BarTender Hero ★
No worries. BarTender doesn't use the full VB but VB Script and so somethings are handled slightly differently
0
Please sign in to leave a comment.
Comments
5 comments