I have items I need to submit to a webhook using the Rules engine. Each item has a few referenced fields. How would I go about resolving multiple referenced fields? This does not work at all.
var jsonObject = {
id:event.id,
tags: [],
categories:[]
};
getReferences(event.data.tags.iv, function(tagNames){
for(var tag of tagNames){
jsonObject.tags.push({
id:tag.id,
tagName: tag.data.tagName.iv
});
}
}
);
getReferences(event.data.categories.iv, function(categories){
for(var cat of categories){
jsonObject.categories.push({
id:cat.id,
tagName: cat.data.displayName.iv
});
}
}
);
JSON.stringify(jsonObject)
Looks like I got it finally working…the jsonObject var had to be defined inside the getReferences function. I’m going to do some more testing with other fields.
getReferences(event.data.tags.iv, function(tagNames) {
var jsonObject = {
id:event.id,
tags: [],
categories:[]
};
for (var tag of tagNames){
jsonObject.tags.push({
id:tag.id,
tagName: tag.data.tagName.iv
});
}
getReferences(event.data.categories.iv, function(categories){
for (var cat of categories){
jsonObject.categories.push({
id:cat.id,
tagName: cat.data.displayName.iv
});
}
});
complete(JSON.stringify(jsonObject));});
Almost there…I can’t get a 3rd reference lookup to work. When I tried to add Authors getRef function, categories ends up being null. If I take out Authors function, categories populates.
getReferences(event.data.tags.iv, function(tagNames) {
var jsonObject = {
id:event.id,
tags: [],
categories:[],
authors:[]
};
for (var tag of tagNames){
jsonObject.tags.push({
tagName: tag.data.tagName.iv
});
}
getReferences(event.data.categories.iv, function(categories){
for (var cat of categories){
jsonObject.categories.push({
category: cat.data.displayName.iv
});
}
});
getReferences(event.data.authorsNew.iv, function(authors){
for (var author of authors){
jsonObject.authors.push({
author: author.data.displayName.iv
});
}
});
complete(JSON.stringify(jsonObject));});