This topic contains 5 replies, has 0 voices, and was last updated by SBatten 6 years, 9 months ago.

  • Author
    Posts
  • #21289

    SBatten

    I have written a script which looks up a multiselect field on the customer record and then sets a field on the sales order when the record is saved.

    I have got it to work by firstly loading the customer record, using nlapigetFieldValues which creates an array of the values.

    If I try to use nlapiLookupField instead I get the values separated by a comma. Is it possible instead to convert this into a string/array like the above?

    We'd ideally like to avoid loading the customer record if possible so if there is a better way then I'd love to hear it!

    Cheers

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

  • #21290

    MChammaTX

    Try using the Javascript split method of the string to convert to an array using the comma delimiter. See documentation here.

  • #21291

    SBatten

    Thankyou very much for the reply.

    I have tried this but for some reason cannot get it to work. If I use nlapiGetFieldValues I get [Ljava.lang.String;@43d6ef2c and if I use nlapiLookupField I get 231,232. I did try using .split("'") but this didn't work.

    Thanks

    Sam

  • #21292

    MChammaTX

    Are you using comma as your delimiter?

    Code:
    var msLup = nlapiLookupField('customer',123,'custentity_somefield');
    var msArr = msLup.split(",");

  • #21293

    j.j

    no commas will not work – use var msf = request.getParameter('multiselectfield'); msf.split(String.fromCharCode(5));

    this will surely work.

  • #21294

    SBatten

    Hi

    Just tried again with .spit(",") and the script is working! Many thanks for the help!

You must be logged in to reply to this topic.