• Roshan Dave
  • NEWBIE
  • 0 Points
  • Member since 2020
  • www.notshout.com

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi All,

I was given this sample JSON by our partner and I am trying to write a REST Web service to ingest it but I can't seem to get it to work. I am testing it in Workbench and am getting this error:

Unexpected parameter encountered during deserialization: orderNumber at [line:2, column:17

Here is the Apex Class:
 
@RestResource(urlMapping='/DPS_Response/')
global with sharing class DPSResposnse
{
    global class AllParties
    {
        global String partyId;
        global String decision;
    }    
    
    @HttpPost
    global static String updateDPSData    (String orderNumber, AllParties[] parties)
    {
       return 'test';
    }
}

And here is the sample JSON:
{
    "orderNumber":"000042289",
    "parties":
       [
      {
        "partyId": "12345",
        "decision":    "D"    
      },
      {
        "partyId": "09876",
        "decision":    "P"        
      }

       ]
}

 

Hey all,

Something is wrong with the code below - it only works (updated Discovery Call Note datetime) if role = Account_executive

How can I update it to also work for Strategic_Account_Executive? 

public class ContentDocumentLinkTriggerHandler {
    /*

    */
    public static void OnAfterInsert(List<ContentDocumentLink> newContentDocumentLink, List<ContentDocumentLink> oldContentDocumentLink, Map<ID, ContentDocumentLink> newContentDocumentLinkMap, Map<ID, ContentDocumentLink> oldContentDocumentLinkMap){
        /*

        */
        UserRole accountExecutiveRole = [Select Id From UserRole WHERE DeveloperName = 'Account_Executive' OR DeveloperName = 'Strategic_Account_Executive' LIMIT 1];
        List<User> AEUserIdList = [SELECT Id FROM User WHERE UserRoleId = :accountExecutiveRole.Id];
        Map<Id, ContentDocument> contentDocumentMap = new Map<Id, ContentDocument>([SELECT OwnerId, Description FROM ContentDocument WHERE OwnerId IN :AEUserIdList]);
        Set<Id> opportunityIdSet = new Set<Id>();
        Map<Id, ContentDocumentLink> opportunityContentDocumentLinkMap = new Map<Id, ContentDocumentLink>();
        for(Id ContentDocumentLinkId: newContentDocumentLinkMap.keySet()){
            if(!RecursionCheck.IsRecordIdInSet(ContentDocumentLinkId, 'After')){
                if(String.ValueOf(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId).StartsWith('006') && ContentDocumentMap.KeySet().contains(newContentDocumentLinkMap.get(ContentDocumentLinkId).ContentDocumentId)){
                    opportunityIdSet.add(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId);
                    opportunityContentDocumentLinkMap.put(newContentDocumentLinkMap.get(ContentDocumentLinkId).LinkedEntityId, newContentDocumentLinkMap.get(ContentDocumentLinkId));
                }
                RecursionCheck.AddRecordIdToSet(ContentDocumentLinkId, 'After');
            }
        }
        //List<ContentDocument> cdList = [SELECT Id, Title, CreatedDate, Description, ParentId, LatestPublishedVersionId FROM ContentDocumentLink WHERE Id = :];

        Map<Id, Opportunity> opportunityMap = new Map<Id, Opportunity>([Select Id, StageName, RecordTypeId, Discovery_Call_Date__c, Use_Case__c, Type, Amount, Discovery_Call_Note_Datetime__c FROM Opportunity WHERE Id IN :OpportunityIdSet]);
        for(Id oppId: opportunityMap.keySet()){
            if(opportunityMap.get(oppId).StageName == 'Qualify'){
                opportunityMap.get(oppId).Discovery_Call_Note_Datetime__c = System.Now();
            }
        }
        // TODO: should I use this or the regular update?
        Update opportunityMap.values();
    }
}