Anyone know why I'm getting the divide by zero err...
# suitescript
j
Anyone know why I'm getting the divide by zero error with this formula?
'<style>.progress{overflowhidden;height18px;background-color:#ccc;border-radius4px; webkit box shadowinset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{floatleft;width0;height:100%;font-size11px;line height18px;color:#fff;text-aligncenter;background color#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}</style><div class="progress">' || '<div class="progress-bar" style="width:' || CASE WHEN ROUND({quantityshiprecv}/NULLIF({quantitybilled}*100, 1)) >= 100.0 THEN 100 ELSE ROUND({quantityshiprecv}/NULLIF({quantitybilled}*100, 1)) END || '%;"> ' || ROUND({quantityshiprecv}/NULLIF({quantitybilled}*100, 1)) || '%</div></div>'
s
if
quantitybilled
is zero then your entire denominator will be zero.
you might want
NULLIF({quantitybilled}*100,0)
?
j
I have tried it with a 0 instead of a 1 and it's the same result
a
If you are trying to make a progress bar, give this a shot:
Copy code
'<style>progress { height: 15px; text-align: center; font-size: 10px; background-color:red } progress:after { content: attr(value)"%"; } </style><progress value="' || {field}*100 || '" max="100">'
Note that my {field} has a max value of 1 so I am multiplying it by 100.
j
'<style>progress { height: 15px; text-align: center; font-size: 10px; background-color:red } progress:after { content: attr({quantityshiprecv})"%"; } </style><progress value="' || {quantitybilled}*100 || '" max="100">'
This is what I used, but it does not show a bar that is less than full when the transaction is partially billed. It either shows 0% or 100%
a
Your max needs to be quantity
not 100. You need to adjust the base code to make it work.
j
ok let me try - sorry im not a coder lol
'<style>progress { height: 15px; text-align: center; font-size: 10px; background-color:red } progress:after { content: attr({quantityshiprecv})"%"; } </style><progress value="' || {quantitybilled}*100 || '" max={quantityshiprecv}>'
same result
a
Other way. Max= quantity or {quantitybilled}
j
same result
a
'<style>progress { height: 15px; text-align: center; font-size: 10px;} progress:after { content: attr(value)"%"; } </style><progress value="' || ROUND(({quantitybilled}/{quantity})*100,2) || '" max="100">'