0

I'm trying to use JSforce library to create/update class using the tooling object. Please note that it is only in sandbox, I do know that in production org it won't work.

Anyway, I'm able to create the class, but when the class already exists and trying to update, it return an error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: insufficient access rights on cross-reference id

I'm thinking it happen because for update we should use ApexClassMember and ContainerAsyncRequest, but I'm not sure if and how those components can be used with JSforce, or I should stop using JSforce and instead use Http rest from apex to invoke the relevant API calls.

if(existingApexClassId){
    conn.tooling.sobject('ApexClass').update(
            {
                Id : existingApexClassId,
                body: apexClassBody},
            function(err, res) {
                if (err) { return console.error(err); }
                console.log(res);
    });
}   
else{
    conn.tooling.sobject('ApexClass').create({
        body: apexClassBody
    }, function(err, res) {
        if (err) { return console.error(err); }
        console.log(res);
    });
}
1
  • No. I know how to do it using HTTP rest call. I trying to understand if it can be done with the Jsforce library – Liron C Jul 5 '20 at 18:23

Browse other questions tagged or ask your own question.