You need to sign in to do that
Don't have an account?
Anonymous Developer
Need help to convert Flow to code
This is the Flowand this is how it runs
Loop CollaborationGroupMemberRequest Status = Pending
Get Account Where ContactId = $Record>UserId>ContactId
Get MembershipGroup Where Group_Id__c contains Loop CollaborationGroup Id
If Account Type Contains MembershipGroup Type{
Id = Loop CollaborationGroupMemberRequest Id
update Status = Accepted
}else{
create Task update ActivityDate to CurrentDate
}
the bold ones are the objects while the italics are the fields.
Thanks in advance
Loop CollaborationGroupMemberRequest Status = Pending
Get Account Where ContactId = $Record>UserId>ContactId
Get MembershipGroup Where Group_Id__c contains Loop CollaborationGroup Id
If Account Type Contains MembershipGroup Type{
Id = Loop CollaborationGroupMemberRequest Id
update Status = Accepted
}else{
create Task update ActivityDate to CurrentDate
}
the bold ones are the objects while the italics are the fields.
Thanks in advance
Hi,
You can use this code , hope this will help you.
for(ColloborationGroupMemberRequest request : [SELECT Id, Status, CollaborationGroupId, RequesterId From CollaborationGroupMemberRequest WHERE Status = 'Pending' AND CollaborationGroupId = :collaborationGroupId]){
Account accList = [SELECT Id, type From Account WHERE ContactId = : request.RequesterId];
MembershipGroup__c grp = [SELECT Id, type__c FROM MembershipGroup__c where Group_Id__c LIKE : request. CollaborationGroupId LIMIT 1];
if(accList.Type.contains(grp.Type__c)){
request.Status = 'Accepted';
update request;
}else{
Task taskIns = new Task();
taskIns.OwnerId = UserInfo.getUserId();
taskIns.Subject = 'Membership request pending';
taskIns.ActivityDate = Date.today();
taskIns.WhatId = request.CollaborationGroupId;
insert taskIns;
}
}
Please mark it as the best answer if it will help you.
Thanks
All Answers
the bold ones are the objects while the italics are the fields.
Thanks in advance
Hi,
You can use this code , hope this will help you.
for(ColloborationGroupMemberRequest request : [SELECT Id, Status, CollaborationGroupId, RequesterId From CollaborationGroupMemberRequest WHERE Status = 'Pending' AND CollaborationGroupId = :collaborationGroupId]){
Account accList = [SELECT Id, type From Account WHERE ContactId = : request.RequesterId];
MembershipGroup__c grp = [SELECT Id, type__c FROM MembershipGroup__c where Group_Id__c LIKE : request. CollaborationGroupId LIMIT 1];
if(accList.Type.contains(grp.Type__c)){
request.Status = 'Accepted';
update request;
}else{
Task taskIns = new Task();
taskIns.OwnerId = UserInfo.getUserId();
taskIns.Subject = 'Membership request pending';
taskIns.ActivityDate = Date.today();
taskIns.WhatId = request.CollaborationGroupId;
insert taskIns;
}
}
Please mark it as the best answer if it will help you.
Thanks