function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
_Prasu__Prasu_ 

DML operation INSERT not allowed on CaseTeamMember

I am trying to create a CaseTeamMember from  apex with Customer Portal user and getting following error.

 

DML operation INSERT not allowed on CaseTeamMember

Error:

 

Does Customer Portal license has any limitation?

stcforcestcforce

i had a look on the documentation for this object. It does not mention any license based limitation but did list a set of operations to include create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), update(), upsert(). If you are unable to create such an object and your code is good, then logically, it would seem that some form of license based limitation is the only explanation. Have you tried using the exact same code from a different user license?

AnandAgrawalAnandAgrawal

I'm facing the similar issue. It works for other license users. 

 

Prasanna, Did you get the solution for this?

 

Anand

_Prasu__Prasu_

I think it really related to the license, what I did was doing it from future method.

AnandAgrawalAnandAgrawal

List<Case> caseList = [select id,assetId,asset.opportunity__c from case where id in :newCaseList];
Map<ID,Set<ID>> oppCaseIdMap = new Map<ID,Set<ID>>();
for(Case caseObj:caseList){
Set<Id> caseIds = oppCaseIdMap.get(caseObj.asset.opportunity__c);
if(caseIds == null )
caseIds = new Set<id>();
caseIds.add(caseObj.id);
oppCaseIdMap.put(caseObj.asset.opportunity__c,caseIds);
}
List<OpportunityTeamMember> otmList = [select id,opportunityId,userId from OpportunityTeamMember where OpportunityId in :oppCaseIdMap.keySet()];
System.debug('========== Something ========= ' + otmList);
List<CaseTeamRole> crtList = [select id from CaseTeamRole where accessLevel like 'Read%' and PreferencesVisibleInCSP = true];
System.debug('========== Something1 ========= ' + crtList);
List<CaseShare> csList = new List<CaseShare>();
if(otmList!=null && !otmList.isEmpty() && crtList != null && !crtList.isEmpty()){
List<CaseTeamMember> ctmList = new List<CaseTeamMember>();
ID caseTeamRoleId = crtList[0].id;
for(OpportunityTeamMember otmObj:otmList){
for(ID caseId:oppCaseIdMap.get(otmObj.opportunityId)){
CaseTeamMember ctmObj = new CaseTeamMember( parentId=caseId,memberId = otmObj.UserId,teamRoleId =caseTeamRoleId);
ctmList.add(ctmObj);
}
}
/* for(OpportunityTeamMember otmObj:otmList){
for(ID caseId:oppCaseIdMap.get(otmObj.opportunityId)){
CaseShare csObj = new CaseShare( caseId=caseId,UserOrGroupId = UserInfo.getUserID(),CaseAccessLevel='Read');
csList.add(csObj);

}
}
*/
insert ctmList;
}

 

I used this code. and It is giving some weird exception  :System.DmlException: Insert failed. First exception on row 0; first error: OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []