Monday, May 15, 2017

Adding Imanage metadata - JS Example

function AddMetadata(customField, customValue , customDescription, parentValue){
    // return either the cached value or jqXHR object wrapped Promise
var payload ={};
if(parentValue===null){
payload = { database: "Blah",
id: customValue,
description: customDescription,
wstype: customField,
enabled: true,
hipaa: false
};
}
else{
payload = { database: "Blah",
id: customValue,
description: customDescription,
wstype: customField,
enabled: true,
hipaa: false,
parent: {
id: parentValue
},
};
}


    return $.when(
       // cache[ "Token" ] ||
        $.ajax({
url: cache["baseurl"] +'customs/'+ customField,
type: 'post',
headers: {
'X-Auth-Token':cache[ "Token"  ],
'Content-Type': 'application/json'
},
dataType: 'json',
data: JSON.stringify(payload),
            success: function( resp ){
//debugger;
//cache[ "doc_id"  ] = resp.data[0].id  ;
console.log("AddMetadata:success");
            },
failure: function( resp ){
console.log("AddMetadata:failure");
console.log(resp);
            }
        })
    );
}
///////////////////////////////////////////////////////////////

No comments:

Post a Comment