You need to sign in to do that
Don't have an account?
Jerry Niemeyer
I can't get challenge to complete for Automate Post-Workshop Tasks with Invocable Apex
I am trying to complete "Automate Your Business Processes: Build an Automated Workshop Management System: Automate Post-Workshop Tasks with Invocable Apex " and when I click "verify step" I get -
Challenge Not yet complete... here's what's wrong:
Couldn't find the "Thanks" badge in the instructor's Chatter feed after completing a Campaign.
I have rebuilt the flow and the APEX and I can't get it to complete, but the "Thanks" badge IS in the insturctor's feed when I change the campaign to complete, so everything seems to work, I just cant get it to "verify"
Challenge Not yet complete... here's what's wrong:
Couldn't find the "Thanks" badge in the instructor's Chatter feed after completing a Campaign.
I have rebuilt the flow and the APEX and I can't get it to complete, but the "Thanks" badge IS in the insturctor's feed when I change the campaign to complete, so everything seems to work, I just cant get it to "verify"
Try to compare your work with screenshots in the module and make sure the spellings of the name are correct.Please post the screenshots of your work so that I can help you further.
Thanks and Regards
Sandhya
@InvocableMethod(label='Give a Thanks Badge')
global static void giveWorkBadgeActionsBatch(List<GiveWorkThanksRequest> requests) {
for(GiveWorkThanksRequest request: requests){
giveWorkBadgeAction(request);
}
}
public static void giveWorkBadgeAction(GiveWorkThanksRequest request) {
WorkThanks newWorkThanks = new WorkThanks();
newWorkThanks.GiverId = request.giverId;
newWorkThanks.Message = request.thanksMessage;
newWorkThanks.OwnerId = request.giverId;
insert newWorkThanks;
WorkBadge newWorkBadge = new WorkBadge();
// newWorkBadge.DefinitionId should be set to the ID for the Competitor Badge within this Org
WorkBadgeDefinition workBadgeDef = [SELECT Id,Name FROM WorkBadgeDefinition WHERE Name = :request.badgeName Limit 1];
newWorkBadge.DefinitionId = workBadgeDef.Id;
newWorkBadge.RecipientId = request.receiverId;
newWorkBadge.SourceId = newWorkThanks.Id ;
//newWorkBadge.GiverId = request.giverId;
insert newWorkBadge;
WorkThanksShare newWorkThanksShare = new WorkThanksShare();
newWorkThanksShare.ParentId = newWorkThanks.Id ;
newWorkThanksShare.UserOrGroupId = request.receiverId;
newWorkThanksShare.AccessLevel = 'Edit';
insert newWorkThanksShare;
FeedItem post = new FeedItem();
post.ParentId = request.receiverId;
post.CreatedById = request.giverId;
post.Body = request.thanksMessage;
post.RelatedRecordId = newWorkThanks.Id ;
post.Type = 'RypplePost';
insert post;
}
global class GiveWorkThanksRequest {
@InvocableVariable(label='Giver Id' required=true)
global Id giverId;
@InvocableVariable(label='Receiver Id' required=true)
global Id receiverId;
@InvocableVariable(label='Thanks Message' required=true)
global String thanksMessage;
@InvocableVariable(label='Badge Name' required=true)
global String badgeName;
}
}
I cant even save this file anyone plz help me ...
On line 27, instead of
you need to have
This is because WorkThanksShare objects cannot be inserted (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_workthanksshare.htm).
global without sharing class GiveWorkThanksAction {
@InvocableMethod(label='Give a Thanks Badge')
global static void giveWorkBadgeActionsBatch(List<GiveWorkThanksRequest> requests) {
for(GiveWorkThanksRequest request: requests){
giveWorkBadgeAction(request);
}
}
public static void giveWorkBadgeAction(GiveWorkThanksRequest request) {
WorkThanks newWorkThanks = new WorkThanks();
newWorkThanks.GiverId = request.giverId;
newWorkThanks.Message = request.thanksMessage;
newWorkThanks.OwnerId = request.giverId;
insert newWorkThanks;
WorkBadge newWorkBadge = new WorkBadge();
// newWorkBadge.DefinitionId should be set to the ID for the Competitor Badge within this Org
WorkBadgeDefinition workBadgeDef = [SELECT Id,Name FROM WorkBadgeDefinition WHERE Name = :request.badgeName Limit 1];
newWorkBadge.DefinitionId = workBadgeDef.Id;
newWorkBadge.RecipientId = request.receiverId;
newWorkBadge.SourceId = newWorkThanks.Id ;
//newWorkBadge.GiverId = request.giverId;
insert newWorkBadge;
WorkThanksShare newWorkThanksShare = new WorkThanksShare();
newWorkThanksShare.ParentId = newWorkThanks.Id ;
newWorkThanksShare.UserOrGroupId = request.receiverId;
newWorkThanksShare.AccessLevel = 'Edit';
upsert newWorkThanksShare;
FeedItem post = new FeedItem();
post.ParentId = request.receiverId;
post.CreatedById = request.giverId;
post.Body = request.thanksMessage;
post.RelatedRecordId = newWorkThanks.Id ;
post.Type = 'RypplePost';
insert post;
}
global class GiveWorkThanksRequest {
@InvocableVariable(label='Giver Id' required=true)
global Id giverId;
@InvocableVariable(label='Receiver Id' required=true)
global Id receiverId;
@InvocableVariable(label='Thanks Message' required=true)
global String thanksMessage;