Since there is not a built-in function to allow deactivating a group of screen elements, I wrote one. The idea is to pass the group name and active value to a function, which then uses the DOM to cycle through the formfields and update the active attribute accordingly. The reason for wanting to do this is, for example, when adding a customer to the database if we want to capture both a billing and shipment address but want to default to the two being identical, a "Same as shipping" checkbox controls whether the billing address fields are accessible.
Here is an example of the call:
call activate_group("Remit Address", 0)
And here is the function:
function activate_group(groupName, activeValue)
define
groupName string,
dnForm om.domNode,
itemList om.nodeList,
item om.domNode,
n integer,
activeValue integer
let dnForm = ui.interface.getRootNode()
let itemList = dnForm.selectByTagName("Group")
for n = 1 to itemList.getlength() #Get list of groups.
let item = itemList.item(n)
if item.getattribute("text") = groupName then #Find specified group.
let item = item.getfirstchild() #Grab first child.
while item is not null #Loop through group children.
if item.getattribute("active") is not null then #Verify field has active property.
call item.setattribute("active", activeValue) #Set property.
end if
let item = item.getnext()
end while
end if
end for
call ui.interface.refresh()
end function
The problem I'm having is that, although tossing in "display item.getattribute("xxx") shows that the correct values are being retrieved and looped through, "call item.setattribute("xxx", value) doesn't seem to hold. If I loop through with ("active", 0), ("value", "xxx"), or anything else the changes just dissappear. If I trigger the change and then click in the fields, the affected fields flash the appropriate value or flash grey to indicate inactive, but then immediately lose their newly-assigned values.
Any thoughts on the problem here?