• abel reegan 28
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Guest user facing issue "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" in a site without login, even after profile level read access is given and sharing rule created for guest user profile, how can I debug this?

I tried to query in "UserRecordAccess" table for the guest user and it shows that the guest user has read access to that specific record.
lwc component passing param to apex class is null, works fine with standard user login, the issue is only when the guest user accesses it from the site.
Using apex how we can activate and deactivate trigger? As I understand it is only possible using metadata api File-Based Calls. Got an article in combination of vf page and apex code, where package file is uploaded. but in runtime can we create a package file and meta file using apex and then deploy?

thanks in advance.
Using apex how we can activate and deactivate trigger? As I understand it is only possible using metadata api File-Based Calls. Got an article in combination of vf page and apex code, where package file is uploaded. but in runtime can we create a package file and meta file using apex and then deploy?

thanks in advance.
How can we pass 10000 records from Apex class to batch class and update 10000 records of Sobect type lead & contact Opps.

I'm trying to change the owner of 10000 records. so I've created a lwc, where I'll take the user from 1st dropdown  of which user record will need to transfer, 2nd drop down will be to which user it should transfer.

Let me know how i can achieve this
So I created a Apex-class that acts as a webhook to get logs of messages from our Whatsapp API and saves certain parameters in a custom object. When I send a message to our business account, the debug log shows that the webhook works and a custom object is created. However, this record is nowhere to find and it seems like no record is being created. This is the webhook class:
 
@RestResource(urlMapping='/some_url')
global without sharing class WhatsAppWebhook {
    
    private static Final String SIGNATURE_VALID_MESSAGE     = 'Signature Verified';
    private static Final String SIGNATURE_NOT_VALID_MESSAGE = 'Signature could not be verified';
    
    @HttpGet // GET
    global static void doGet() {
        RestResponse response = RestContext.response;
        RestRequest request = RestContext.request;
        if(request.params.get('hub.verify_token') == 'token'){
            response.responseBody = Blob.valueOf( request.params.get('hub.challenge') );
        }
    }
    
    @HttpPost // POST
    global static void doPost() {
        
        RestResponse response = RestContext.response;
        response.addHeader('Content-type','application/json');
        String responseString = RestContext.request.requestBody.toString();
        Map<String, String> headers = RestContext.request.headers;
        String responseValid = validateWhatsAppSignature(RestContext.request, responseString);
        
        if(responseValid == SIGNATURE_VALID_MESSAGE || system.test.isRunningTest()){
            System.debug(System.LoggingLevel.DEBUG, ' Headers Response From WhatsApp \n  '+ JSON.serialize(headers) );
            System.debug(System.LoggingLevel.DEBUG, ' Response From WhatsApp \n  '+ responseString);
            String finalResponseString = responseString.replace('type', 'typex');
            WhatsAppMessage parentMessage = (WhatsAppMessage)JSON.deserialize( finalResponseString, WhatsAppMessage.class);
            List<WhatsAppMessage.entry> messageEntries = parentMessage.entry;
            if(messageEntries != null && messageEntries.size() > 0){
                WhatsAppMessage.entry entryMessage = messageEntries.get(0);
                List<WhatsAppMessage.changes> changeMessages = entryMessage.changes;
                if(changeMessages != null && changeMessages.size() > 0){
                    WhatsAppMessage.changes changeMessage = changeMessages.get(0);
                    List<WhatsAppMessage.contacts> contactList = changeMessage.value.contacts;
                    List<WhatsAppMessage.messages> messageList = changeMessage.value.messages;
                    WhatsAppMessage.metadata metadata = changeMessage.value.metadata;
                    /* Create record into Salesforce */
                    WhatsAppChat__c salesforceMessage = new WhatsAppChat__c();
                    salesforceMessage.Business_Telefonnummer__c = metadata != null ? metadata.display_phone_number : null;
                    
                    if(contactList != null && contactList.size() > 0){
                        WhatsAppMessage.contacts contact = contactList.get(0);
                        salesforceMessage.Klient_Nummer__c = contact.wa_id;
                        salesforceMessage.Klient_Name__c = contact.profile.name;
                    }
                    
                    if(messageList != null && messageList.size() > 0){
                        /* Simple Message */
                        WhatsAppMessage.messages message = messageList.get(0);
                        salesforceMessage.Nachrichten_ID__c = message.id;
                        salesforceMessage.Nachrichtentyp__c = message.typex;
                        salesforceMessage.Nachrichten_Zeitstempel__c = System.now();
                        salesforceMessage.Nachricht__c = message.text != null? message.text.body : null;
                        
                        /* If message is reaction */
                        salesforceMessage.Reaktion__c = message.reaction != null ? message.reaction.emoji : null;
                        salesforceMessage.Kontext_Nachrichten_ID__c = message.reaction != null ? message.reaction.message_id : null;
                        
                        /* If message is Image */
                        salesforceMessage.Bild_ID__c = message.image != null ? message.image.id : null;
                        salesforceMessage.Bildtyp__c = message.image != null ? message.image.mime_type : null;
                        salesforceMessage.Bild_sha256__c = message.image != null ? message.image.sha256 : null;
                        
                        /* If message is Video */
                        salesforceMessage.Video_ID__c = message.video != null ? message.video.id : null;
                        salesforceMessage.Videotyp__c = message.video != null ? message.video.mime_type : null;
                        salesforceMessage.Video_SHA256__c = message.video != null ? message.video.sha256 : null;
                        
                        /* If the message is reply to another message */
                        salesforceMessage.Kontext_Nachrichten_ID__c = message.context != null ? message.context.id : null;
                        
                        upsert salesforceMessage Nachrichten_ID__c;
                    }
                    
                }
            }
        }else{
            response.responseBody = Blob.valueOf('{success:false, event:"Unknown","message:"'+responseValid+'"}');
            response.statusCode = 401;
            return;
        }
        
        response.statusCode = 200;
        response.responseBody = Blob.valueOf('{success:true, event:"success"}');
    }
    
    private static String validateWhatsAppSignature(RestRequest request, String responseString) {
        // Validate Stripe signature Start 
        Map<String, String> headers = request.headers;
        
        String whatsAppSignature = headers.get('X-Hub-Signature-256');
        
        String whatsAppPayload = RestContext.request.requestBody.toString();
        
        // Verify the signature using 'hmacSHA256'. I have the Webhook key stored in a Custom Label
        String whatsAppSecret = System.Label.FBAppToken; // Facebook Application Secret Key
        Blob signedPayload = Crypto.generateMac('hmacSHA256', Blob.valueOf(whatsAppPayload), Blob.valueOf( whatsAppSecret ));
        
        String encodedPayload = 'sha256='+EncodingUtil.convertToHex(signedPayload);
        // Return status code based on whether signed payload matches or not
        
        String response = (encodedPayload == whatsAppSignature)? SIGNATURE_VALID_MESSAGE : SIGNATURE_NOT_VALID_MESSAGE;
        return response;
        // Validate Stripe signature End 
    }
}
This is the class that's also being referred to in above class:
 
public class WhatsAppMessage {
    
    public entry[] entry;
    public class entry {
        public String id;	
        public changes[] changes;
    }
    public class changes {
        public value value;
        public String field;	
    }
    public class value {
        public String messaging_product;	
        public metadata metadata;
        public contacts[] contacts;
        public messages[] messages;
    }
    public class metadata {
        public String display_phone_number;	
        public String phone_number_id;	
    }
    public class contacts {
        public profile profile;
        public String wa_id;	
    }
    public class profile {
        public String name;	
    }
    public class messages {
        public context context;
        public String fromx;	
        public String id;	
        public String timestamp;	
        public text text;
        public String typex;	
        public reaction reaction;
        public image image;
        public image video;
    }
    public class context {
        public String fromx;	
        public String id;	
    }
    public class text {
        public String body;	
    }
    public class reaction{
        public String emoji;
        public String message_id;
    }
    public class image{
        public String mime_type;
        public String id;
        public String sha256;
    }
}

And this snipped of the debug-log shows that the object WhatsAppChat__c is being created:

User-added image
Any suggestion on how to solve this is greatly appreciated.
 
I am trying to deploy  permission set using package.xml in sandbox but facing below issue:
1. In field: application - no CustomApplication named standard__AdvancedTherapyManagement found
2. In field: application - no CustomApplication named standard__PublicSectorInspectionManagement found
3. In field: application - no CustomApplication named standard__TrustCard found
4. In field: application - no CustomApplication named standard__Work found
5. In field: field - no CustomField named
Entitlement.SvcApptBookingWindowsId found

These apps and custom field not possible to remove from permission set because code is already in git.

Also I found this help archicle: https://help.salesforce.com/s/articleView?id=000383597&language=en_US&type=1 
It asked to raise case with salesforce

Any other way to resolve without raising case ? and also how to enable Entitlement.SvcApptBookingWindowsId field in sandbox?