Friday, May 19, 2017

IManage search by metadata in API

since IManage has this horrible bug that search by metadata doesn't work here is a horrible kluge

///////////////////////////////////////////////////////////////
function getProfile(docid){
 return $.when(
        $.ajax({
url: cache["baseurl"] +'documents/'  + docid ,
type: 'get',
headers: {
'X-Auth-Token':cache[ "Token"  ],
'Content-Type': 'application/json'
},
dataType: 'json',
            success: function( resp ){
//debugger;
currentProfile = resp;
console.log("getProfile:success "  + docid);
            },
failure: function( resp ){
console.log("getProfile:failure "  + docid);
console.log(resp);
            }
        })
    );
}
/////////////////////////////////////////////////////////////////////////////////////////////
function SearchDoc(params ){
    // return either the cached value or jqXHR object wrapped Promise
var temp;
    return $.when(
        $.ajax({
url: cache["baseurl"] +'documents/search',
type: 'get',
headers: {
'X-Auth-Token':cache[ "Token"  ],
'Content-Type': 'application/json'
},
dataType: 'json',
success: function( resp ){
temp = resp.data.filter(function(item) {
getProfile(item.id)
//debugger;
if(currentProfile !== null){
for(var key in params) {
//debugger;
if(currentProfile.data[key] === undefined || currentProfile.data[key] != params[key])
return false;
}
return true;
}
else{
return false;
}

});
debugger;
//return temp;
              //  cache[ "doc_id"  ] = resp.data[0].id;
console.log("getDoc:success");
            },
failure: function( resp ){
console.log("getDoc:failure");
console.log(resp);
            }
        })
    );
}
///////////////////////////////////////////////////////////////
p ={custom4:"2015"};
getToken().then(SearchDoc(p))

No comments:

Post a Comment