Beginner question regarding fileid for category assignment

Started by hluxem, August 14, 2017, 05:52:07 PM

Previous topic - Next topic

hluxem

Hello all,
I'm playing around with an app and try to assign categories to a single file out of a file selection.
I'm able to assign a category to the file selection with this code.
IMWS.post('v1/categories/unassign',{
path: '6 Workflow|IM-TEST',
fileidlist: IMatch.idlist.fileWindowSelection
});


After reading the documentation and playing around for too long, I still can't figure out how to assign a category to just one file.
I tried using fileid:
IMWS.post('v1/categories/assign',{
path: '6 Workflow|IM-TEST a',
id: selid
});

selid is the id of the focused file. I don't get an error message, but no file is assigned to the category. It says in the documentation fileid takes a comma-separated list of file ids. I want only one file, is using just a number wrong? In my case the selid is 236448 and I tried just the number as well. I get retrieve this number with the following function"
IMatch.getFocusedFile().then(function(response) {
selid = response.id;
});


I couldn't find any sample just assigning a value to one file, so I'm stuck, any help is greatly appreciated.

Thanks,
Heiner


thrinn

Hello Heiner,
the parameter name is wrong:
id would be the id of the category you want something to assign to. To provide the id of the file, use fileid. Your description is correct, but your code sample shows id: selid.
Thorsten
Win 10 / 64, IMatch 2018, IMA

hluxem

Great,
That helped a lot, tried out too many different combinations. Using a number or variable and assigning the number to it with "fileid: ..." worked.
Still had the problem that using the selid variable I retrieved with the function did not work. Little more research showed that the retrieved variable is an object and I had to use  "fileid: selid[0]".
Now I can go off to more exploring and learning.


Thanks a lot,

Heiner