Use Lawson Smart Office Scripting to move a field
October 1, 2012
by Sam Green
Lawson Smart Office scripting is a very useful tool for customizing forms. One of the most common uses is to move an existing input field somewhere else on the form. This may be needed in order to make room for other custom fields or buttons, or it may be needed just because it makes better sense for your business to have the field show up in a different place for your users. Watch the video below for a quick tutorial on how this is done.
What IForm Function would be used if you wanted to move a field that is not contained on a tab but exists in the detail area of a form (ex. PR35.2, I want to swap the hours and paycode fields).
Regards,
Joe
Sorry, that really isn’t possible in Infor Smart Office 10.0.4.
Look for a Infor Smart Office update very soon that will introduce a new IForm method for that purpose: MoveDetailElement:
MoveDetailElement Function
Returns: boolean
It moves a standard FrameworkElement on each row of a detail area. It also returns a boolean indicating succes or failure of the move operation.
Nitty gritty details:
Parameters
name: string – The data name of the element to move (without row number)
row: int – An integer value of the detail line row on which to place the element or -1 if no change
col: int – An integer value of the column on which to place the element
tabName: string – If a detail tab field, the name of the tab on which to place the element
Hi Keith. Can you use script to manipulate elements of detail lines with newer versions of Smart Office? We are using security to block users from using particular FCs on a detail line. It would be nice to take that FC out of sight and out of mind for the users.
I used the method described to move a few fields from one tab to the front tab. The issue is that those fields don’t work now. They are all drop downs but when I try to click them they stay blank and don’t respond at all. Any ideas?
Nathan: The majority of the detail line functions were added in 10.0.5. Some additional functions, Move, Remove, Add Label were added in 10.1.0.
Also, there is a function in Smart Office Scripting which allows the removal of items from built-in selections lists…those that are defined in the form definition. The function to use is RemoveComboBoxItem(string FieldName, string DataValueToRemove) and returns True/False for the success of the function. For detail rows, you would need to loop through the rows and do this function for the field on each row.
Nicholas: Be sure to hide any fields, whether visible by default or not, in the destination location via Tools | Personalizations | Show/Hide Fields. If clicking on the moved field doesn’t work, it may be because it is, in effect, underneath the existing field. Hiding the field takes care of the problem.
Is there an IForm function to move a field from one Lawson form to another? Ie) Move the “Reference” field on GL45.2 to GL45.1?
Chris: There is no single function to move a field from one form to another. What you would need to do is to add a textbox to the destination form and then write script to populate that textbox. For your specific example, the fields from GL45.2 are hidden on GL45.1 so you would just need to get and set the hidden field on GL45.1. If it was not hidden on the form, you would need to write script to do Transaction Service or Data Service calls to populate the field and then update the value on the other form via a Transaction Service Call.
Is it possible to move an existing label without declaring or creating a new one? If so, which function do you use?
Stephanie: Unlike other fields in the form definition, labels do not have unique identifiers and may be on a form more than once. Because of that, the only option is to hide the current label in its position via Personalization | Show/Hide Fields | Unconditional and then add it again with the AddCustomLabel function in the Controls Utilities of the Helper selections in the upper right corner of the Script Tool window.
I am unable to resolve the ‘Could not find class declaration’ error message I am getting when attempting to compile a script via the script tool in LSO. I also can’t find any documentation in either the LSO manual or inforxtreme. Thoughts??
Which item in which row of your code is causing that error? The compile error message has (a,b) in it where a is the row and b is the location in that row. If you double-click on that error you will be taken to that location.