RE: How do I get ID of all files attached to a record?
I need to get the ID, and other info, for every file attached to a Customer record. I created a Saved Search in the UI which gives me what I need. However if I load and run the search, or create a search, in a User Event Script, in beforeLoad, (or in the Debugger) I get no values. If I use search.lookupFields I get the information from only one file. In the code below, I know that Customer ID 3 has two files attached. In the log you can see it found two entries, but I get no information. And lookupFields gives the same information twice.
search.create({ type: "customer", filters:[{"name":"internalid","operator":"anyof","values":["3"]}], columns:[ {"name":"url","join":"file"}, {"name":"filetype","join":"file"}, {"name":"companyname"} ] }).run().each(function(res) { log.debug('url: '+res.getValue('url')+', type: '+res.getValue('filetype')+', name: '+res.getValue('companyname')); var fld = search.lookupFields({ type: search.Type.CUSTOMER, id: 3, columns: ['file.internalid','file.name','file.filetype'] }); log.debug(fld); return true; });
Log:
debug url: null, type: null, name: Anonymous Customer
debug {“file.internalid”:[{“value”:”421″,”text”:”421″}],”file.name”:”8Q Signature Capture on Forms.pdf”,”file.filetype”:[{“value”:”PDF”,”text”:”PDF File”}]}
debug url: null, type: null, name: Anonymous Customer
debug {“file.internalid”:[{“value”:”421″,”text”:”421″}],”file.name”:”8Q Signature Capture on Forms.pdf”,”file.filetype”:[{“value”:”PDF”,”text”:”PDF File”}]}
Thank you for your answer. Forgive my ignorance, but I don’t understand what you are saying. If by “parameters” you mean “url” and “filetype” and “companyname” I do have them the same in the search.createColumn as in the Result.getValue. I have tried using
columns: [“file.url”, “file.filetype”, “companyname”]
and
res.getValue(“file.url”), res.getValue(“file.filetype”), res.getValue(“companyname”)
and get the same result. I do get the information I need with search.lookupFields, but I can’t figure out how to get that for all attached files.
If you would be so kind as to give me some sample code, perhaps it would help.