Anyone out there have a form that uses div(numerator, denominator)
Im trying to create a form that will take the content of one field divide it by 2 then going into a string.
NOTE: div() will only return an integer. (i.e. div(11, 2) = 5)
You should be able to just use str() to convert your int back into a string. Or am I misunderstanding what you are trying to do?
str(div(val(DOCUMENT.FIELD),2))
I was about to edit the post to elaborate,
So basically I have a field for the total number of pellets. In my documentation I have my string setup like: ...."this that the other " + strcc + " more stuff"
So where strcc is that is my total pellet field which is a dropdown list variable.
End goal is to have the division execute when something is selected or typed in that dropdown to push the divided result to strcc. So if my dropdown choice is 10 the string for documentation will read: ...."this that the other " + 5 + " more stuff"...
But before I can get close I'm having trouble getting the div function to work with a document variable. In the MEL trace I get:
08/13/2014 10:07:56.329-execute>call DIVIDEPELLETS()
08/13/2014 10:07:56.329-execute>Document.PELLETS_5825_900_1407937537
08/13/2014 10:07:56.329-results>"14"
08/13/2014 10:07:56.329-execute>call DIV("14", 2)
08/13/2014 10:07:56.329-results>ERROR: 32783 INVALID OPERATION OR BAD SYMBOL TYPE
ERROR: 32783 INVALID OPERATION OR BAD SYMBOL TYPE
So I tried it with what I know works like:
{str(div(PATIENT._AGEINMONTHS,12))} and noticed with the call DIV("14",2) the numerator doesn't have quotations.
Yup, so just change Document.PELLETS_5825_900_1407937537 to val(Document.PELLETS_5825_900_1407937537). Or whatever you have it called in VFE.
Thank you! thank you! now on to the next step.
Any idea how to get this to trigger without a button?
Not sure exactly what you are doing, but maybe try this in your code instead of a function:
{!
if (DOCUMENT.PELLETS <> "") then
strcc = str(div(val(DOCUMENT.PELLETS), 2))
else "" endif
}
Or call the function in the translation. You may need to have DOCUMENT.PELLETS as a parameter to get the function to fire off whenever DOCUMENT.PELLETS is changed.
So I pulled this piece out to work on separately. Test Division
I've probably gone way off track since starting it at 8 this morning lol
This is the whole piece,
Alrighty thank you again for the help so now if I could just get this into my larger string.