I am writing a script that will make a copy of a v...
# suitescript
j
I am writing a script that will make a copy of a vendor. I need to also copy the Contacts from the Vendor to the copy. (Yes I know I could do save-as but our use case requires this to go via script instead). I can’t seem to get anything out of the
contact
sublist. It shows when I do vend.getSublists() but the lineCount comes back as 0 and I can’t retrieve any values, even though there are Contacts on the record. Any ideas?
Basically, how do I a) iterate through contacts on a vendor and then b) add those contacts to another vendor, using SuiteScript.
n
How are you doing it in the script? Share your code.
Which script type are you using?
j
Client
I’m just testing in browser console for now. one sec
message has been deleted
A quick google suggests others have experienced the same problem 😞
a
load in dynamic mode?
j
same result
n
Can you expand vend object?
And see what's there
j
not sure quite if I’m understanding, it will show all available methods
the method is valid, it’s just returning 0 lines for that sublist
when it’s definitely not zero.
other sublists work as expected.
n
Just print the vend object in console
It will show the sublists
j
I’m not sure how to do that
message has been deleted
n
Do a load record without saving it to a variable
j
message has been deleted
see, no lines
even though there ARE contacts on this vendor
I think this is a NS bug
e
From Oracle Communities Q&A Contact sublist is scriptable. Instead of getSublistField(which return the field object), use getSublistValue(to get the value of specific field). Please take note that 'contactroles' internalid is used for the Contacts under Access Subtab while 'contact' internalid is used for Contacts under Relationship subtab. https://community.oracle.com/netsuite/english/discussion/4477979/contact-sublist-is-this-scriptable
Note that the question is about Customer Contacts, but maybe it applies to vendors all the same
j
I can’t
getSublistValue
because it thinks
lineCount
= 0 for this sublistId
I know how to work with sublists, I’ve done it many times. It’s just like the record doesn’t load the
contacts
sublist at all, simply reports that there is one.
same problem w/customers
weird
n
can you do like this in console: record.load({}) without dynamic mode?
j
that link above isn’t loading for me BTW, the oracle one
weird
n
contact sublist is not available on CS
message has been deleted
e
Same link I posted before: "Apologies for the confusion. Contacts in the relationship Subtab cannot be directly access through Customer Records via Scripting. It is also not included on the Records Browser. However, you can make use of Search related functions to get the contact details."
j
right ok
j
so I’m not crazy
fudge
n
Record browser also doesn't list contact as valid sublist.
j
how’m I gonna populate my copy
annoying!
n
You can use search module
j
not to populate I can’t
n
why not? Get the values from search and populate it manually.
j
populate it manually
<- how to do this if contact sublist is not scriptable?
in SuiteScript
n
I think you can create contact and attach it...
I think I did it once...
I cannot seem to recall it at the moment.
j
but I’m not creating contacts. I’m just attaching existing ones.
maybe I can use
record.attach
will experiment
n
You will need to copy the contact then as well.
j
no
same contact
n
Test and see if attach works, but I doubt it.
j
attached to two vendors
pretty sure
record.attach()
will work
n
there is "company" field on the contact which works as a "parent" for that contact.
j
that’s different though
n
So based on this, I am assuming you will need to create a contact copy.
but see if record.attach can resolve your issue.
j
I’m talking about the list of contacts under the relationships tab on vendor record
those can be contacts that do NOT have that vendor listed as their “company”
it can be any contact, actually
it controls what contacts you can send emails to from the record
also you can assign roles
I think it will work
s
the moral of the story is - just because something renders in a subtab in NS doesn't mean it's a sublist?
I can say for
Customer
the
contactroles
sublist works - I see code using it. Not seeing any client script references to it though. Only server-side
but don't see anyone using it to create lines - looks like you can just create the contact record independently, setting the
company
field to the parent entity (e.g. vendor id)
For the more loose relationship between contact/vendor, I think your record.attach() idea is the only other option I'm aware of?
j
further to the above, I’m now stuck on how to tell what roles people actually had