About Project Item's ID
Hi everyone,
I can get an item's ID with : var id = app.project.item.id;
like id = 966900432;
but if I have an number : 966900433;
my question is how to judge this number is legal or not?
thanks;
Hi everyone,
I can get an item's ID with : var id = app.project.item.id;
like id = 966900432;
but if I have an number : 966900433;
my question is how to judge this number is legal or not?
thanks;
There's default method app.project.itemByID(itemID) that get's project item by ID. However, it will raise error if such itemID is not valid. To overcome this, use it in try/catch block.
var itemID = 1;
var item = getItemByID(itemID);
alert(item);
function getItemByID(itemID) {
try {
return app.project.itemByID(itemID);
} catch(e) {
return null;
}
}
Hope that helps.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.