I would like to have three different fields populated based on what is selected in the first. I tried to add it all in one but it didn't work.
I ended up having to split them out.
{!if OBSNOW("AG_V1_1") == "American Cockroach" then
DOCUMENT.VEN_V1_1 = "ALK"
endif
}
{!if OBSNOW("AG_V1_1") == "American Cockroach" then
DOCUMENT.LOT_V1_1 = "3233401"
endif
}
{!if OBSNOW("AG_V1_1") == "American Cockroach" then
DOCUMENT.EXP_V1_1 = "09/20/2021"
endif
}
The issue is that I have 41 more antigens to do this with. I would like a neater/easier way to write this.
Please let me know if you have questions. Screenshot of what we are trying to do is attached.
Consider using the condition (cond) statement instead. Understand that it looks for a TRUE condition then exits when it finds it, thereby ignoring the rest.
Example:
{
cond
case OBSNOW(“AG_V1_1″) == “American Cockroach” DOCUMENT.VEN_V1_1 = “ALK”
case OBSNOW(“AG_V1_1″) == “American Cockroach” DOCUMENT.LOT_V1_1 = “3233401″
case OBSNOW(“AG_V1_1″) == “American Cockroach” DOCUMENT.EXP_V1_1 = “09/20/2021″
else ""
endcond
}
Also, you may wish to avoid using the ! since obsterms have issues initializing on load.
Edit - I missed that the document values are different, Daniel's response is correct. However, since you have multiple values to manage, you can use conditional statements for each document variable 'set'.
ie.
{
cond
case OBSNOW(“AG_V1_1″) == “American Cockroach”
DOCUMENT.VEN_V1_1 = “ALK”
DOCUMENT.LOT_V1_1 = “3233401″
DOCUMENT.EXP_V1_1 = “09/20/2021″
case OBSNOW(“AG_V1_1″) == “...”
DOCUMENT.VEN_V1_1 = “...”
DOCUMENT.LOT_V1_1 = “...″
DOCUMENT.EXP_V1_1 = “...″
else ""
endcond
}
The code above should work when combined. I would just write the code like this:
{if OBSNOW("AG_V1_1") == "American Cockroach" then
DOCUMENT.VEN_V1_1 = "ALK"
DOCUMENT.LOT_V1_1 = "3233401"
DOCUMENT.EXP_V1_1 = "09/20/2021"
endif}
I don't know if your actual code has mixed types of quotation marks, but your examples above have different opening quotes and closing quotes. That can cause some code to fail, so it is good to always make sure your code is consistent in a program like notepad++.
If you try copying the code I wrote, and it still fails, let me know. I would suspect that there is another issue going on.
Thank you,
Daniel Carpenter