Column PostValidate

I have a column postvalidate script called when a user selects a udf field using a UDT for validation.

Essentially the script gets the returned value from the UDF lookup, then opens the UDT and gets

another value out of the table.

Table columns

UDF_MANAGER_CODE      UDF_MANAGER_NAME

003                                             Joe

004                                             Bill

005                                             Tracy

The script works fine when you pick the first MANAGER_CODE, and inserts the UDF_MANAGER_NAME in another UDF on the form.

Here's the problem. When you return to the form and select the same UDF_MANAGER_CODE, the postvalidate script does not run.

Only if you pick a DIFFERENT UDF_MANAGER_CODE does the postvalidate script execute.

The reason it's important, is because the underlying UDT table has a new UDF_MANAGER_NAME, and I expect the postvalidate script to

run and populate the other udf field with the new value.

Kind of confusing, but my hunch is I don't exactly understand how the postvalidate logic works.

Dim manager_code
Dim manager_name

retval = 0
oUDT = 0
bugval = 0

manager_code = ""
manager_name = ""

retVal = oBusObj.GetValue("UDF_MANAGER_CODE$", manager_code)

Set oUDT = oSession.AsObject(oSession.GetObject("CM_UDTMaint_bus", "AR_UDT_ACCT_MANAGER"))

retval = oUDT.SetKey(manager_code)


if(retval = 1) then
'get value from UDT
retVal = oUDT.GetValue("UDF_MANAGER_NAME$", manager_name)

'assign value to current biz obj
retVal = oBusObj.SetValue("UDF_MANAGER_NAME$", manager_name)

end if

  • 0

    if i'm not mistaken, post validate only runs if the value is different, so if a field contains ABC and you lookup and return ABC or key in ABC over it, the prior value and the entered value are the same so it doesn't trigger the post validate.  You might be able to try a pre validate and see if that fires it.

    Do you really need to be changing the manager name?  Why not just add a new code for the new name?

    Do you really need to have the name in the table?  Could you not just have the code and then pull the name in reports and use the next step to handle displaying the value in any entry/inquiry tasks?

    Setting up the UDF to use the UDT as validation should allow you to select any UDFs from the UDT as a "display only" value in Customizer.  Then you can set the display only control's options so it is borderless.

    If I then change the value in the UDF and reload the item, the new value is displayed.

    If you are unable to use the above feature, you may need to first remove the reference to your UDF in the main table from the panel and save it, then make sure the UDF is using the UDT for validation, update the table again if needed, and then add the code UDF back to the panel and then you should see the UDT used for validation in the list of other sources.  If for some reason you still can't get that to work, you can always use a post read and post validate script to change the value of the locked UDF that you already have for the name using the UI object's SetControlProperty method to set the "Value$" property (this won't trigger the business object to validate or write the value to the table when the record is saved so it should always be blank but you can also force it to be blank first using SetValue to make sure it always stays blank) but this way the name is never stored in the table but is read on the fly in the task.

    Something else you can do is use VI Export Job Maintenance and select any job or start a new job and select any table, the goal is to click the Links button so you can set up your own link between the main table and your UDT using the UDF in the main table as the link.  Here is an example of setting up a link to a UDT where the key is the item code.  This will let you use the link in lookups.

  • 0 in reply to David Speck

    David,

    It looks to be the case, but the validate event should call the script regardless. Sage is making the assumption there aren't any other validation processes tied to the script.

    Five stars for the effort. You really push out logical thought.

    Bret