1

As per the official Developer Guide, we can do DML operations on "PresenceUserConfigUser".But while inserting PresenceUserConfigUser records I'm getting an error saying "DML operation Insert not allowed on PresenceUserConfigUser".Please advise on this.

2 Answers 2

1

I was also looking for a solution to this issue. Tried multiple ways, but was not able to get any solution.

At last, tried with Flow and was surprised to see that we can do this using flow.

You can use Flow for DML operation on PresenceUserConfigUser object.

1

We had a similar request. DML can be performed using composite REST API. Note that only 25 records can be inserted at one callout.

SAMPLE CODE:

public class requestBodyWrapper {
    public List<CompositeRequest> compositeRequest;
}

public class CompositeRequest {
    public String method;
    public String url;
    public String referenceId;
    public Object body;
    CompositeRequest(string componentType){            
        if(componentType == 'PresenceUserConfigUserAddition'){
            this.Body = new PresenceUserConfigUserBody();
        }
        
    }
}


public class PresenceUserConfigUserBody {
    public String PresenceUserConfigId;
    public String UserId;
}   

public void makeRequestMethod(){
    CompositeRequest comp = new CompositeRequest('PresenceUserConfigUserAddition');
    comp.method = 'POST';
    comp.url = '/services/data/v55.0/sobjects/PresenceUserConfigUser';
    comp.referenceId = String.valueOf(**your index of iteration**);
    PresenceUserConfigUserBody bod = new PresenceUserConfigUserBody();
    
    bod.PresenceUserConfigId = XXXXXXXX                 
        bod.userid = XXXXXXXX
        comp.body = bod;
    compositeRequestList.add(comp);
    
    //Code piece for callout
    requestBodyWrapper requestBodyWrapperInstance = new requestBodyWrapper();
    requestBodyWrapperInstance.compositeRequest = compositeRequestList;
    
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('POST');        
    req.setHeader('content-type', 'application/json');
    req.setHeader ('Authorization', 'Bearer ' + userinfo.getSessionId()); 
    req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+ '/services/data/v55.0/composite/');
    req.setBody(JSON.serialize(requestBodyWrapperInstance));   
    system.debug('Request '+JSON.serialize(requestBodyWrapperInstance));
    HttpResponse res = h.send(req);
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .