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

  • Author
    Posts
  • #17791

    aliakas

    When creating a new record type of VENDOR how do I go about setting / saving the select list options?

    For example, the vendor record has a subsidiary field which is a select field type. How can I save a new subsidiary to my new vendor record?

    I’ve been able to pull data on the text fields and saving data to text fields seems easy enough. Having trouble with select and tab fields though.

    Thanks for your help!
    This is a cached copy. Click here to see the original post.

  • #17792

    Olivier Gagnon NC

    record.setValue

  • #17793

    aliakas

    Perhaps I am making this harder than it should be? Your response was helpful, I was able to save a new vendor record – thanks!

    What I am having trouble with is this.

    Let’s say I have a subsidiary name. I could search the subsidiary table and find it, but what value from this could I use to save my new vendor?

    Below in my code I used 1, but I am not sure how that ties back to the subsidiary table.

    Thanks again for your help!

    Code:
    record.create({
    type: record.Type.VENDOR,
    isDynamic : false,
    defaultValues: null
    }).setValue({
    fieldId: ‘externalid’,
    value: ‘gps_test_123’,
    }).setValue({
    fieldId: ‘companyname’,
    value: ‘ABC Payme’
    }).setValue({
    fieldId: ’email’,
    value: ‘gps@testcompany.com’
    }).setValue({
    fieldId: ‘phone’,
    value: ‘111-222-3333’
    }).setValue({
    fieldId: ‘subsidiary’,
    value: 1
    }).save({ enableSourcing: true,
    ignoreMandatoryFields: false} );

  • #17794

    Olivier Gagnon NC

    I’m not sure I understand your question. You should set the appropriate Subsidiary for this vendor. I do not see how you could not know the correct value. If for some reason you have the correct textual value but not the ID you can use that via setText rather than firing a search (unless you have a partial subsidiary name…?).

    If you don’t know what Subsidiary to attribute to a vendor, you need to pause coding and review your business requirements.

  • #17795

    MChammaTX

    You can query the subsidiary table using the search module then read the id using result.id, which corresponds to what you would set in the setValue method.

You must be logged in to reply to this topic.