Forum Discussion
So I solved this after a deeper dive on the Programmer's Guide. A few things unlocked, 1) the Validate event expects a true or false to come out of it as the result and 2) the way that properties are fetched isn't quite the same as what you'd use on a form.
I also got it to use the Aras dialog (thanks to this thread! https://community.aras.com/f/getting-started/37434/aras-confirm-dialog---are-there-any-alternatives-or-updates-to-improve-the-lock-feel)
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:abbc25d8-441a-4869-921a-23847c1edb82:type=javascript&text=const%20currentItem%20%3D%20aras.itemsCache.getItem%28itemId%29%20%7C%7C%20aras.itemsCache.getItemByXPath%28%60%2F%2FItem%5B%40id%3D%22%24%7BitemId%7D%22%5D%60%29%3B%0D%0Aconst%20classification%20%3D%20aras.getItemProperty%28currentItem%2C%20%27classification%27%2C%20%27%27%29%3B%0D%0Aconst%20parentpkg%20%3D%20aras.getItemProperty%28currentItem%2C%20%27_parent_package%27%2C%20%27%27%29%3B%0D%0Aconst%20relatedproj%20%3D%20aras.getItemProperty%28currentItem%2C%20%27_relatedproject%27%2C%20%27%27%29%3B%0D%0A%0D%0A%2F%2Fdialog%20box%20details%0D%0Aconst%20title%20%3D%20%22Confirm%20Missing%20Value%22%3B%0D%0Aconst%20image%20%3D%20%22..%2Fimages%2FWarning.svg%22%3B%0D%0Aconst%20okButtonText%20%3D%20%22Save%20Anyways%22%3B%0D%0Aconst%20dialogoptions%20%3D%20%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20title%2C%0D%0A%20%20%20%20%20%20%20%20image%2C%0D%0A%20%20%20%20%20%20%20%20okButtonText%2C%0D%0A%20%20%20%20%20%20%20%20okButtonModifier%3A%20%27aras-button_secondary%27%0D%0A%20%20%20%20%7D%3B%0D%0A%0D%0A%0D%0Aif%20%28classification%20%3D%3D%3D%20%22Tagged%20Component%22%29%7B%0D%0A%20%20%20%20var%20message%20%3D%20%22Tagged%20Components%20should%20be%20assigned%20to%20a%20Parent%20Package%22%3B%0D%0A%20%20%20%20if%20%28value%20%3D%3D%3D%20null%29%20%7B%0D%0A%20%20%20%20%20%20%20%20if%20%28window.parent.ArasModules.Dialog.confirm%28message%2C%20dialogoptions%29.then%28function%28res%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20switch%28res%29%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20case%20%27ok%27%3A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20window.onSaveCommand%28%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20valid%3A%20true%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20default%3A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20valid%3A%20false%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20validationMessage%3A%20%60Assign%20%24%7B_parent_package%7D.%20Tagged%20Items%20need%20to%20be%20assigned%20to%20a%20parent.%60%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%29%29%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0A%2F%2FOtherwise%2C%20return%20a%20valid%20result.%0D%0Areturn%20%7B%0D%0Avalid%3A%20true%0D%0A%7D%3B]
The validation message part doesn't actually work at the moment, but it's not holding me up anyways. Figured I'd share the code in case anyone else might be interested.
But... my main hang-up now is that if the user doesn't pick on that field, it doesn't seem that the validation event is run. So if they edit everything else, but don't pick on that field (which isn't set to required, because it's context-specific required), it doesn't alert them. Does anyone know of a way to have a method to check for validity on all the fields before a Save or Done?
Follow-up on this is have been able to get a dialog to trigger on an empty field using a Form-linked event; however it only seems to work when the event is "onFormPopulated". When it's set to "onBeforeUnload" (which I'm presuming is meant to be before it's unlocked, but can't find documentation saying that), it never seems to trigger.
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:5bab9a13-c679-464e-85df-d32b82e8b298:type=javascript&text=var%20parentpkg%20%3D%20document.thisItem.getProperty%28%22_parent_package%22%29%3B%0D%0A%0D%0Aif%20%28parentpkg%20%3D%3D%3D%20undefined%29%20%7B%0D%0A%20%20%20%20aras.confirm%28%22Parent%20Package%20is%20missing.%20%20Should%20be%20assigned%22%29%3B%0D%0A%7D]
This is without any fancy styling at this point.
Appreciate any additional thoughts on this.