Well, that API call returns the full list, which I might be able to use; however, it wouldn't be quite as convenient as getting the list of items in the supplier workspace. This is because although I said previously that I'm "finding the dmsID of the supplier with the same name as the one specified in the SolidWorks userform", I'm more specifically finding the supplier with a URL field that matches the domain of the source URL of the part being added to PLM. This minimizes the number of inputs required in the SolidWorks userform.
Here is the code from my macro where I find the supplier:
With CreateObject("MSXML2.DOMDocument")
.loadXML SuppHTTP
'Derive supplier information based on the source URL
Dim TempXML As MSXML2.DOMDocument, InSuppURL As String, _
ind1 As Integer, ind2 As Integer
InSuppURL = Split(UserFormImportPart.TextBoxSrcURL, "/")(2)
For ind1 = 0 To .getElementsByTagName("item").Length - 1
SuppID = .getElementsByTagName("id")(ind1).Text
Set TempXML = CreateObject("MSXML2.DOMDocument")
TempXML.loadXML .getElementsByTagName("item")(ind1).xml
For ind2 = 0 To TempXML.getElementsByTagName("key").Length - 1
If TempXML.getElementsByTagName("key")(ind2).Text = "NAME" Then
SuppName = TempXML.getElementsByTagName("value")(ind2).Text
ElseIf TempXML.getElementsByTagName("key")(ind2).Text = "URL" Then
SuppURL = Split(TempXML.getElementsByTagName("value")(ind2).Text, "/")(2)
If SuppURL = InSuppURL Then GoTo Bypass
End If
Next ind2
Next ind1
MsgBox "Supplier not found"
Exit Sub
End WithWhere SuppHTTP is the response from the request getting the list of items in the supplier workspace, UserFormImportPart.TextBoxSrcURL is the URL to the supplier's site for that part, and Bypass is the portion of code immediately following this that I want to skip to when I find the supplier URL that matches the one specified.
I guess at this point my options are as follows:
- Figure out why some of the suppliers are not being included in the response to the List workspace items API call but are being included in the response to the Retrieve picklist API call.
- Figure out how to create a picklist connecting the supplier's URL to its dmsID.
- Add an additional input to the SolidWorks userform for the user to explicitly specify the supplier.
- Create and maintain a local copy of the supplier list that mirrors the one in PLM.
Of those options, #2 sounds ideal since that would result in a smaller response from the API and less information to sift through; however, it looks like a picklist can connect the dmsID only to the corresponding item name, not to an arbitrary field from that item. Option #3 would undoubtedly work, but it would require more input from the user, and I would like to avoid that if possible. Similarly, option #4 would also work, but I'd also like to avoid having to update that list whenever a new supplier is added.
That leaves just option #1 and figuring out the source of the problem that led to this post.
Thanks for your help! I greatly appreciate it!