Saturday, November 24, 2018

Ability to set the custom form of a transaction on a per user basis.

 

This article will show users how to create a script that set the custom form of a transaction on a per user basis.

1. Create a custom entity field for the employee that will have the value of the preferred form of the employee.  Customization > Lists, Records, & Fields > Entity Fields > New
    Set the following:
     Label: Preferred Form
     ID: _so_form
     Type: List/Record
     List/Record: Transaction Form
     Store Value: Checked
     Applies To: Employee
     Save.
2. Create a new client script.  Customization > Scripting > Scripts > New > Client
3. Enter information needed on the Basic Information:
     Name: (name of your script)
     Scripts > Script: Upload the sample script Below.
     Page Init Function: setForm
     Deployments > Applies to: Sales Order or any transaction.
                   Deployed: Yes
                   Status: Released
    Save

Sample script:

function setForm(name){
    if (name == 'create') {
        var user = nlapiGetUser();
        var needed = nlapiLookupField('employee', user, 'custentity_so_form');
        var current = nlapiGetFieldValue('customform');
        
        if
(current != needed) {
            nlapiSetFieldValue('customform', needed, false, true);
        }
    return true;
    }
return true;
}

Note: This is alternate solution for Enhancement 213781/179692

No comments:

Post a Comment