Sunday, March 31, 2019

Return Currently Selected Line Item on Address of a Customer Record via nlapiGetCurrentLineItemIndex

If one needs to get an alert on every click out of the Address book sublist in the customer record, set up the client script below. The API will return the line number selected. Using the API returns a more consistent value than just returning a parameter like linenum.

1. Setup > Customization > Scripts > New > Client
2. Upload the script below and reference the function name (testOne) on the Field Changed Function

function testOne(type)

{

  if(type=='addressbook'){

var poppin = nlapiGetCurrentLineItemIndex('addressbook');

alert(poppin);

  }

}


3. Save and Deploy the Client Script
4. On the Script Deployment, set the following below.
-- Applies To: Customer
-- Audience > Roles = All Roles = T
5. Save

Note: Clicking the "Add / Edit" button will always return the current number of items plus 1. As the button label states, it has two functions wherein updated / changed line items are saved and a new line item is selected at the end when clicked. So if you edit line item 2 on a list of 5 line items and hit the "Add / Edit" button, the changes will be saved to line item 2 but the alert will return 6.

No comments:

Post a Comment