This topic contains 2 replies, has 0 voices, and was last updated by chanarbon 7 years, 8 months ago.

  • Author
    Posts
  • #1256

    kentroylance

    Is there a way to retrieve a list of status codes with their description so I don’t have to do the following for every record I retrieve?

    var status = nlapiLoadRecord(‘customerstatus’,’7′);

    var name = status.getFieldValue(‘name’);

    Thanks,

    Kent
    This is a cached copy. Click here to see the original post.

  • #1257

    erictgrubaugh

    What are you building that requires this functionality? What are you trying to accomplish?

    To answer your specific question, you can do a search once to retrieve all elements of the `customerstatus` list:

    Code:
    var results = nlapiSearchRecord(“customerstatus”, null, null, [new nlobjSearchColumn(“name”)]);
    You can then get the ID or the names of each element from there. For instance, if I wanted to generate a list of all the possible status names:

    Code:
    function toName(result) {
    return result.getValue(“name”);
    }

    var names = results.map(toName);
    In my environment, `names` is now:

    Code:
    [
    “Closed Lost”,
    “Closed Won”,
    “Dead”,
    “Identified Decision Makers”,
    “In Discussion”,
    “In Negotiation”,
    “Lost Customer”,
    “New”,
    “Opportunity Identified”,
    “Proposal”,
    “Purchasing”,
    “Qualified”,
    “Renewal”
    ]

  • #1258

    chanarbon

    You may also load the record in the script debugger, perform a getField() then perform a getSelectOption() on your customerstatus field

You must be logged in to reply to this topic.