• Ashish Singh SFDC
  • NEWBIE
  • 345 Points
  • Member since 2018
  • Salesforce Developer and Administrator
  • RightKliq


  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 90
    Replies
Hello all,

I am very new to APEX, and I am trying to match the Account Id of one custom object to another customer custom object. I am using this code into Lightning Component, so I have used @AuraEnabled. I am getting variable does not exist error for variable 'besuchsbericht'. Here is my code snippet:
public class PriceBookEntriesFromAccount {
    
    @AuraEnabled
    public Id currentBB{get; set;}
    
    public PriceBookEntriesFromAccount(ApexPages.StandardController controller) 
    {
        currentBB = Apexpages.currentpage().getParameters().get('id');
    }
    
    @AuraEnabled
    public list<Besuchsbericht__c> besuchsbericht = [SELECT Unternehmen__r.Name FROM Besuchsbericht__c WHERE Id =:currentBB];
   
    @AuraEnabled
    public static List<BB_Produkt__c> getPriceBookEntries() {
        List<BB_Produkt__c> bb = 
            [SELECT Name, Id, Produkt__r.Name, Verkostung__c, Kaufinteresse__c, Unternehmen__r.Name 
             FROM BB_Produkt__c 
             WHERE Unternehmen__r.Name = :besuchsbericht];
        //Add isAccessible() check
        return bb;
    }
}
My apologies for some variable names in the German language.
Any help would be appreciated. 

Thank you!
Maitreyee Dingare
@isTest
private class AccountWrapper_Tests {
  @testSetup
  static void loadTestData(){
    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
    List<Opportunity> opps = new List<Opportunity>();
    for(Account a : accounts){
      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
// anyone tell me where to see for that variable wether it is there are not?
    } 
    insert opps;
  }

  @isTest static void testPositiveRoundedAveragePrice() {
    List<AccountWrapper> accounts = new List<AccountWrapper>();
    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
      accounts.add(new AccountWrapper(a));
    }
    // sanity check asserting that we have opportunities before executing our tested method.
    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
    Test.startTest();
    for(AccountWrapper a : accounts){
      System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
    }
    Test.stopTest();
  }
    

      @isTest static void testHighPriority() {
        List<AccountWrapper> accounts = new List<AccountWrapper>();
        for(Account a : [SELECT ID, Name FROM ACCOUNT]){
            accounts.add(new AccountWrapper(a));}

          
            List<Opportunity> opps = new List<Opportunity>();
            opps = [SELECT Id,Amount FROM Opportunity];
              for(Opportunity opp :opps ) {
                  opp.amount =2000000;
              }
          update opps;
    
    Test.startTest();
      for(AccountWrapper a : accounts){
      System.assertEquals(a.isHighPriority(), true, 'Priority expected to be high');
      System.debug('get rounded price of opps for accounts b:'+ a.getRoundedAvgPriceOfOpps());
    }
    Test.stopTest();
  }
}
How to write apex test for void method with custom settings?I have a list custom setting.
 
public string name {get;set;}
    public string name2{get;set;}
    public String setting_1{get; set;}
    public String setting_2{get; set;}


public void set(){
        myuser__c setting = myuser__c.getInstance('mydata');
        name = setting.data__c;
        name2= setting.data2__c;
    }
    
    public void save(){
        myuser__c setting = myuser__c.getInstance('mydata');
        setting.data__c = setting_1;
        setting.data2__c = setting_1;
        update setting;
    }
    
    public void reset(){
    myuser__c setting = myuser__c.getInstance('mydata');
        setting.data__c = '';
        setting.data2__c = '';
        update setting;
    }
 
@isTest
private class SettingsTest{
    
    
    @testSetup static void setup() {

    myuser__c setting = new myuser__c();
        setting.Name = 'data__c';
        setting.data__c = 'test_name';
        //setting.Name = 'data2__c';
        //setting.data2__c = 'test_name2';
        insert setting;
    }

     static testmethod void testSetCustomSettings() {
       Settings myclass = new Settings();
       myclass.set();


    }
    
}

when I run the test it gives the error:  System.NullPointerException: Attempt to de-reference a null object
 Below code was intended to do dynamic search on Case object and display results in pageblocktable. Now, I have added inlineEditSupport and save function to it. As I want to save values in inputField "Case Review Notes" field (Case_Comments_On_VFReport__c). When I click on Save button, it does save value, but only on UI. When I refresh page, value is gone. Also when I tried to query Case_Comments_On_VFReport__c in devconsole I don't see any update on this field.
I am just trying to get hands on Visualforce page and Apex. Can you guys please help me here with code?

Visualforce Page:
<apex:page controller="VF_CaseSearch" action="{!searchCase}" tabStyle="Case" sidebar="false">
    <apex:form >
        <apex:pageBlock>

            <apex:pageblockSection >
                <apex:inputText value="{!cas.CaseNumber}" label="Search Case Number"/>
            </apex:pageblockSection>
            
            <!---Search Button--> 
            <apex:pageblockButtons location="bottom">
                <apex:commandButton value="Search" action="{!searchCase}"/>
            </apex:pageblockButtons>
            </apex:pageBlock>
 
        <apex:pageBlock title="Case Details" id="details" rendered="{! IF( caseList != null && caseList.size >0, true, false)}" mode="edit">
            <apex:pageBlockTable value="{!caseList}" var="c">  
                <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
                <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/> 
                <apex:column value="{!c.Status}" headerValue="Status"/>
                <apex:column value="{!c.Severity__c}" headerValue="Priority"/>
                <apex:column headerValue="Case Review Notes">
                    <apex:inputField value="{!c.Case_Comments_On_VFReport__c}" />
                </apex:column>
            </apex:pageBlockTable>
           <apex:inlineEditSupport />
            
                    <!---Save Button -->
                    <apex:pageBlockButtons html-align="left" location="top">
                          <apex:commandButton value="Save" action="{!save}" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Custom Controller:
public with sharing class VF_CaseSearch {

  public Case cas{get;set;}
  public List<Case> caseList {get;set;}
  List<string> conditions = new List<string>();
  
    public VF_CaseSearch(){
      cas = new Case();
  }
  
  public void searchCase(){
      if(caseList !=null && caseList.size()>0){
          caseList=null;
      }
      searchCase**s** ();
      conditions.clear();
  }
  
  
  public Void searchCase**s**(){
      if(caseList != null && !caseList.isEmpty()){
          caseList.clear();
      }

      //create a dynamic query for filter results
      String strQuery ='SELECT Id, CaseNumber, CreatedDate, Status, Severity__c, Case_Comments_On_VFReport__c, FROM Case';
    
      if(cas.SAC__c !=null && cas.SAC__c !=''){
          conditions.add('SAC__c Like\'%' +cas.SAC__c +'%\' ');
      }
           
      if (conditions.size() > 0) {
          strQuery += '  WHERE  ' + conditions[0];
          for (Integer i = 1; i < conditions.size(); i++)
              strQuery += '  AND  ' + conditions[i];
      }
      
      caseList = Database.query(strQuery);
  }
    
     // Save button
     public PageReference save(){
        try{
            Database.update(caseList);
            system.debug('caseList'+ caseList);
            return ApexPages.CurrentPage();
        }
        catch(DMLException e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,e.getMessage()));
        }
        return null;
    }
}


 
Hello All,
Having an issue passing a list to another method within a class.

So I have this code:
public list<Cand__c> tc1;

 Cand__c tc1 = [my query]
How fo I pass the results of tc1 to another method in the class?
This code below is not working.  The list is null
public void summary ( list<Cand__c> new cand)

Any suggestions would be greatly appreciated.

Cheers,
P


 
So basically i have a page that is going through case creation, if the contact doesn't exist it, there is a button that shows the user a contact creation section.
When I press save I get errors that make no sense.

Visualforce
<apex:page Controller="CaseProcess" lightningStylesheets="true" >
    <apex:form >
        <apex:pageBlock Title ="Case Creation">
            <apex:pageMessages></apex:pageMessages>
            <apex:pageBlockSection title="Case Setup" id="caseSetup">
                <apex:inputField value="{!newCase.Subject}" required="true"/>
                <apex:inputField value="{!newCase.Origin}" required="true"/>
                <apex:inputField value="{!newCase.AccountId}" required="true"/>
                <apex:inputField value="{!newCase.RecordTypeId}" required="true"/>
                <apex:inputField value="{!newCase.ContactId}" required="true"/>
                <apex:inputField value="{!newCase.EntitlementId}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection>
                <apex:commandButton value ="New Contact" action = "{!showCreateContact}" rendered = "{!notWizardContactSection}" immediate="true" html-formnovalidate="formnovalidate" style="align-content: center">
                	<apex:actionSupport reRender="contactCreation" />
            	</apex:commandButton>
            </apex:pageBlockSection> 
            <apex:commandbutton value="Save Case" action="{!saveCase}"/> 
    		<apex:commandbutton value="Cancel" action="{!cancelCase}" immediate="true" html-formnovalidate="formnovalidate"/>
        </apex:pageBlock> 
        <apex:pageBlock id="contactCreation" rendered="{!wizardContactSection}" title="Contact Creation">
            <!-- create contact section -->   
            <apex:pageBlockSection >
                <apex:inputField value="{!newContact.Name}"/>
            	<apex:inputField value="{!newContact.FirstName}" />
                <apex:inputField value="{!newContact.LastName}" id="lastName" />
                <apex:inputField value="{!newContact.AccountId}" id="accountId"/>
                <apex:inputField value="{!newContact.Email}" />
                <apex:inputField value="{!newContact.MobilePhone}" />
            </apex:pageBlockSection>  
            <apex:pageBlockSection>
                <apex:commandButton value ="Save Contact" action = "{!saveContact}" immediate="true" html-formnovalidate="formnovalidate">
                    <apex:actionSupport reRender="contactCreation" />
                </apex:commandButton>
            </apex:pageBlockSection>
            <!-- buttons section -->
        </apex:pageBlock>
    </apex:form>
</apex:page>
Controller
 
public class CaseProcess {

    public Contact newContact{get; set;}
    public Case newCase{get; set;}

    
    // assign variables for the different sections of the form
    public boolean wizardContactSection{get; set;}
    public boolean notWizardContactSection{get; set;}
    
    public CaseProcess(){
        // assign variables for hidding and showing sections of the form
        newCase = new Case();
        newContact = new Contact();
        wizardContactSection = false;
        notWizardContactSection = true;
    }
    public pagereference cancelCase(){
        return new pagereference('/lightning/o/Case/list');
    }
    public pagereference saveCase(){
        newCase.Status = 'New';
        insert newCase;
        return new pagereference('/lightning/o/Case/list');
    }
    
    public void showCreateContact(){
        wizardContactSection = true;
        notWizardContactSection = false;
        newContact.AccountId = newCase.AccountId;
    }
    public void saveContact(){
        /*
        if (newContact.AccountId == null){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please add an account to the contact.'));
            return;
        }*/
        try{
            insert newContact;    
        	newCase.ContactId = newContact.Id;
        	wizardContactSection = false;
        }
        catch(DmlException ex){
        	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));   
        }
    }

}

And error message
User-added image
I can't work out why, I have tried moving all the contact related stuff into an extention but that doesn't work either 

 
Hello, our Contact object has a lookup to our Lead object. When a Lead is inserted or updated, and certain custom fields are not null, a trigger automatically creates a Contact record. One of those custom Lead fields is a rich text area, because after the Contact is inserted, we want to turn that into a hyperlink which can be clicked on to go straight to the Contact record. What would you advise as the best way to do this? Any help in building the trigger would be greatly appreciated. 
I have created a VF page using a custom controller and I wanted to change background colour of the pageblocksection as it defaults to blue. The issue is it changes in the preview but when I add it to sites it defaults to blue.

Preview:
User-added image
Using Sites:

User-added image
<apex:page controller="i2" >
    <style>
.bPageBlock {
border-top: 0px;
}
</style>
    <apex:form>
        <apex:pageBlock title="Invoice" mode="maindetail">
            
            
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            <apex:pageblockButtons location="Bottom" >
                <apex:commandButton action="{!save}" value="save" >
                </apex:commandButton>
            </apex:pageblockButtons>
            
            
            <apex:pageBlockSection columns="1" title="Invoice Details">
                <apex:inputField value="{!acc.Name}"/>
                <apex:inputField value="{!acc.Total_Amount__c}"/>
                <apex:inputField value="{!acc.Password__c}"/>
             	
   
            	</apex:pageBlockSection> 
            
            
            <apex:pageBlockSection columns="1" title="Invoice Line Items Details">
                <apex:inputField value="{!abb.Name}"/>
                <apex:inputField value="{!abb.Price__c}"/>
                <apex:inputField value="{!abb.Invoice__c}"/>
            </apex:pageBlockSection> 
            
        </apex:pageBlock>
    </apex:form>
    
    
    
</apex:page>

 
Hi Friends,

I have a requirement, where I need to insert child records based on date difference.

Below details:
After insert trigger on Order to insert a child custom object based on start date and end date difference.
For Eg: Start Date = 28/02/2020 and End Date = 28/03/2020.
Difference is 29 days and I want to create 29 child records.

How can I start writing the trigger. Kindly give your suggestions.

Thanks in Advance.
I have a visualforce page and a custom controller
vf page have a form and required fields and i'm validating it throught <apex:inputtext value="{!data}" required="true">

my question is do I need to validate it in my controller also?
like if
if(data == Null || data == ''){
   pexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'my error message'));
}
i'm really confused about it.

please help.


 
trigger BaltimoreNo on Account (before insert) {
    for (Account acc : Trigger.new){
        if (acc.BillingCity='Baltimore'){
            alert ('Company XYZ will not do business in city of Baltimore');
     
        }
    }
}
Hi all,

I've requirement where we are want to move from Unlimited edition to enterprise edition. If someone has done it in past, could you please help us with consideration, challenges, checklist, etc.

I've already explored lot of conent on web but couldn't found much relevant information. 

Thanks,
Ashish Singh.
Hi Experts,

I have requirement to write a trigger on user object. Whenever a user is created or updated based on the profile, I need to assign the permission set. I have created 2 custom object for this: Profile__c (master) and Permission_Set__c(detail). In Profile I have Saved a record name__c: "Standard Employee" and Id__c="15 digit Id " of real profile & same way I have created 3 records in Permission Set with name__c with original name of Permission Set and Id__c for its child record.  I have to do this using custom object because we have around 124 permission Set which will continued to be added.

Trigger :
trigger permissionSetAssignment on User(after insert, after update){
    if(trigger.IsAfter && trigger.IsInsert){
        PermissionSetAssignment_Handler.afterInsert(Trigger.new);
    }
    if(trigger.IsAfter && trigger.IsUpdate){
        PermissionSetAssignment_Handler.afterUpdate(Trigger.oldMap,Trigger.new);
    }
}

Handler Class for Update:

public class PermissionSetAssignment_Handler {
    public static void afterInsert(List<User> users){
     /* Logic Yet to be written*/      
    }
    public static void afterUpdate(Map<Id,User> oldUsers, List<User> newUsers){
        Set<Id> userIds = new Set<Id>();
        Map<Id,User> userPerm = new Map<Id,User>();
        List<PermissionSetAssignment> insertList = new List<PermissionSetAssignment>();
        for(User u:newUsers){
            User checkUser = oldUsers.get(u.ID);
            if(u.ProfileId != checkUser.ProfileId){
                userIds.add(u.Id);
            }
        }
        List<PermissionSetAssignment> psa = [Select Id from PermissionSetAssignment where assigneeId in:userIds and permissionSetId in (Select Id from PermissionSet where IsOwnedByProfile=False)];
        delete psa;
        List<Profile__c> profiles = [SELECT Id,Id__c,name,(Select Id,Id__c,name from Permission_Sets__r) FROM Profile__c];
        List<Permission_Set__c> permissionSets = [Select Id,Id__c from Permission_Set__c];
        for(User u:newUsers){
            for(Profile__c pc:profiles){
 /* Here I am stucked I want to fetch only those permissionSets which are under under profile but with below code I'll end up adding all permission Sets */               
                if(u.ProfileId == pc.Id__c){                   
                    for(permission_Set__c ps:permissionSets){
                    PermissionSetAssignment sep = new PermissionSetAssignment();
                    sep.AssigneeId=u.id;
                    sep.PermissionSetId=ps.Id__c;
                    insertList.add(sep);
                    }
                }
            } 
    }
            insert  insertList;        
}
}
Hi,

I have 3 custome objects
1. Session - Fileds(Date, Description, Level, Session Name

2. Session Speaker (Junction object) has following fields:-
* Session - Master detail(Session)
* Session Speaker Number - auto number
* Speaker - Master Detail(Speaker)

3. Speaker- fields (Owner and Speaker number)

I have written a trigger to not allowing double bookings of Sessions but it is not working properly. The conflict variable does not pull up any record that are conflicting. My trigger is as follows:-

//Trigger to detect double booking
//for the session speaker
trigger rejectDoubleBooking on Session_Speaker__c (before insert, before update) {
    LIST<Session_Speaker__c> speakers = new LIST<Session_Speaker__c>();
    SET<ID> speakerId = new SET<ID>();
    LIST<Session__c> allSessions = new LIST<session__c>();    
    for(Session_Speaker__c sessionSpeaker : trigger.new) {
    speakerId.add(sessionSpeaker.Session__c);
        speakers.add(sessionSpeaker);
        system.debug('speakerId' + speakerId);
    system.debug('sessionspeaker' + sessionSpeaker); 
        system.debug('speakers' + speakers);
    }
    LIST<Session__c> ses = [SELECT ID, Session_Date__c 
                            FROM Session__c
                            WHERE Id =:speakerId];
   system.debug('ses' + ses); 
    
    LIST<Session_Speaker__c> conflicts = [SELECT Id
                                             FROM Session_Speaker__c
                                            WHERE Speaker__c =:speakerId
                                          AND Session__r.Session_Date__c =:ses];
    system.debug('conflicts' + conflicts);
       
         //If conflicts exist, add an error (reject the database operation)
            if(!conflicts.isEmpty()){
            //sessionSpeaker.addError('The speaker is already booked at that time');           
        }
    //}

}

Please help as I am stuck.

Thanks
Vijay
Hello Guy's,

Is it possible to send out an email to receipient on every 5th case closure.

Appreciate your inputs on the same......

Regars,
VSK98

 
  • July 14, 2021
  • Like
  • 0
Hello, I am trying to get code coverage for a trigger, but am having trouble writing unit tests. The purpose of the trigger is to throw an error when a user tries to close a Case with outstanding Tasks associated with the record. Here is the trigger
public class OpenTaskHandler {
    
    public static void getCaseList(List<Case> triggerNew, Map<id, Case> newMap){
    	Set<Case> newlyClosedCaseIds = new Set<Case>();
        
    	for (Case caseId : newlyClosedCaseIds)
    	{
        	if (caseId.IsClosed)
        		{
                	newlyClosedCaseIds.add(caseId);
            	}
    	}
    
    	for (AggregateResult aggResult : [ 
        	SELECT Count(Id), WhatId From Task WHERE WhatId In :newlyClosedCaseIds AND isClosed = false
        	Group by WhatId
        	having Count(Id) > 0
    	]) {
        	Case openCase = (Case) aggResult.get('WhatId');
        	Case errorCase = newMap.get(openCase.Id);
        
        	errorCase.addError('Cannot close case since there are non closed tasks: ' + errorCase.Id);
    	}
}
Here is one of my tests:
@isTest public class CaseTaskTriggers {
    @isTest public static void TestOpenTasks() {
        
       Case testCase = new Case();
        testCase.Status='New';
        insert testCase;
        
       Task tsk = new Task();
        tsk.Subject = 'New hire has been added';
        tsk.WhatId = [select Id from Case Limit 1].Id;
        tsk.OwnerId = UserInfo.getUserId();
        tsk.Status = 'New';
        insert tsk; 
        
        Test.startTest();
        
        try{
            testCase.Status = 'closed';
            update testCase;
        }
        Catch(Exception ee){}
        
        system.assertNotEquals(tsk.Status = 'Closed', tsk.Status = 'New', 'Cannot close case since there are non closed tasks');
        
        test.stopTest();
    }
I am getting red code coverage on the if (caseId.IsClosed) {newlyClosedCaseIds.add(caseId), the Case openCase = (Case) aggResult.get('whatid') and the errorCase.addError. How do I account for these on a unit test? I am fairly new to unit testing and would love any tips/feedback. Thanks !

 
Hello, I want to ask, currently my org using USD currency. But our customers are from different countries so will have a few different currencies. As we all know, the currency rate will change from time to time. May I know to convert the USA to their own currency automatically without us changing the rate every time? Is there any way?

At this moment I have one field for the amount in the USA, and 1 field is the customer currency code like MYR, ect. If I do the formula, means we need to update the rate from time to time. Is there any other way to solve this issue?

For this question, I park under the Apex code because I am not sure which section its falls.
@HttpGet
     global static void sendMail(){
        RestRequest request = RestContext.request;
        String accountId = request.params.get('id');//error
        system.debug(accountId);
        Account objAccount = [SELECT Id,Name,(SELECT Id,Name FROM Contacts) FROM Account WHERE Id = :accountId LIMIT 1];
        
    
   // global static void sendMail(){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{'varsha.rcr37@gmail.com'}; 
 mail.setToAddresses(toAddresses);
     
//Contact con = [SELECT id, firstname FROM Contact LIMIT 1];
EmailTemplate et = [SELECT id FROM EmailTemplate WHERE developerName = 'gmail_salesforce'];
 

 
mail.setTargetObjectId(objAccount.id); 
mail.setTemplateId(et.id);
        
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
     }
}
INVALID QUERY
The query has to start with 'FIND' or 'SELECT'.
How to solve this problem
Can you please give an example for each it would be really helpful.
Thank You
How would turn this visulforce related list that shows files that are attached on a parent account on a service appointment record. The below code works, but doesnt look appealing and I need to add it a community.

User-added image
<apex:page standardController="ServiceAppointment">
<apex:relatedList subject="{!ServiceAppointment.Account_Name__c}" list="AttachedContentDocuments" />
</apex:page>

 
I am creating a detail page link in a page layout.
I have created a report and wanted this detail page link to point to my report based on the Campaign Name.
How do I create a custom url for this?

Any suggestions please?
Hi,
I am just starting with apex class, triggers and integration patterns.
My goal is that, whenever an account is created in Salesforce, I want to make a REST callout to an external service with the data in the account.
Based on research, I found that I will have to create an apex class with an HTTP service to make a REST API call.
But from where should I invoke this apex class? When an account is created/updated, an apex class should be invoked to make a REST API call to an external service.
Can anyone please guide me on this?

Thanking you in advance. 
Hello!

I am working on building a month over month report for our pipeline. Essentaially I would like to compare the dollar amount in each stage of the pipeline to the previous month. Is there a formula I can use to create a feild that shows me the amount of money in each stage of the pipeline last month?
I am trying to implement reCaptcha in LWC. 
I only complete example I find is here in the blog post 
Blog Post (https://www.learnexperiencecloud.com/s/article/Implementing-reCAPTCHA-in-Community-Cloud). 

Now my question is where do we expose the site key in LWC. 
If someone can guide me with an example for implementation of any version of reCaptcha in LWC that would be helpful.
I currently have a C# Web Application that is creating new Accounts in Salesforce using REST API. 

I would like to check for duplicates prior to creating the records using REST API. 

I recently discovered Sforce-Duplicate-Rule-Header (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_duplicaterules.htm). 

After adding the header to my HTTP Requests, I expected to receive a response with all fields in the duplicate record when the record being created is determined to be a duplicate based on my Duplicate Rules for Account Object.

Am I misinterpreting what this header is supposed to do for me?

HTTP Request (POST / Create for an Account that already exists):
Method: POST, RequestUri: 'https://XXXXX.my.salesforce.com/services/data/v52.0/sobjects/Account', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  Accept: application/json
  Authorization: Bearer XXXXX
  Sforce-Duplicate-Rule-Header: allowSave=false; includeRecordDetails=true; runAsCurrentUser=true
  Content-Type: application/json; charset=utf-8
},
Content:
{
  "Name":"Test Account",
  "First_Name__c":"Test",
  "Last_Name__c":"Account",
  "BillingStreet":"123 Main St",
  "BillingCity":"Pittsburgh",
  "BillingState":"PA",
  "BillingPostalCode":"12345",
  "Phone":"1234567890"
}
HTTP Response:
{
  "id":"XXXXX",
  "success":true,
  "errors":[]
}

Because the account already exists, I'd expect to get back all fields in the duplicate record.  At very least I'd expect something other than a successful creation. 

Am I misinterpretting what this header does or how to use it? 
Hi,

I am generating a bearer token in API. Now, I want to add a condition to regenerate a new bearer token for every 6 days. 
This is my code:
-------------------
public class qcOauth {
    public static string AuthCode(){
        string Authcode;
        qc__c    Qc = qc__c.getvalues('qc details');
        authWrapreq Aw = new authWrapreq();
        Aw.clientId = Qc.Consumer_Key__c;
        Aw.username = Qc.UserName__c;
        Aw.password = Qc.Password__c;
        
        string endpoint = Qc.url__c+'verify';
        HttpRequest request = new HttpRequest();
        request.setEndpoint(endpoint);
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json');
        String jsonBody = JSON.serialize(Aw);
      //  system.debug('JSON BODY : '+jsonBody);
        request.setBody(jsonBody);
        Http http = new Http();
        HttpResponse response = http.send(request);
     //   system.debug('response body: '+response.getBody());
        if(response.getStatusCode() == 200){
            authRes res = (authRes)json.deserialize(response.getBody(), authRes.class);
            authcode = res.authorizationCode;
        }
     //   system.debug(authcode);
        return authcode;
    }
    
    public static string BearerToken(){
        string BearerToken;
        qc__c    Qc = qc__c.getvalues('qc details');
        BearerWrapReq Bw = new BearerWrapReq();
        Bw.clientId = Qc.Consumer_Key__c;
        Bw.clientSecret = Qc.Consumer_secret__c;
        Bw.authorizationCode = Authcode();
        
        string endpoint = Qc.url__c+'token';
        HttpRequest request = new HttpRequest();
        request.setEndpoint(endpoint);
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json');
        String jsonBody = JSON.serialize(Bw);
    //    system.debug('JSON BODY : '+jsonBody);
        request.setBody(jsonBody);
        Http http = new Http();
        HttpResponse response = http.send(request);
     //   system.debug('response body: '+response.getBody());
        if(response.getStatusCode() == 200){
            BearRes res = (BearRes)json.deserialize(response.getBody(), BearRes.class);
            BearerToken = res.token;
        }
     //   system.debug(BearerToken);
        return BearerToken;
    }

    public class authWrapreq{
        public string clientId;
        public string username;
        public string password;
    }
    public class authRes{
        public string authorizationCode;
    }
    public class BearerWrapReq{
        public string clientId;
        public string clientSecret;
        public string authorizationCode;
    }
    public class BearRes{
        public string token;
    }
}

Any Idea how to do this?

Thanks,
Kezia
 
I would like to be able to close a toast event (shown using ShowToastEvent in LWC Javascript) from the Javascript - if the user hasn't closed it yet and the 3 seconds timer hasn't elapsed - and a called Apex method has returned.

Is this possible? If so, how is it done?
Can one query an Object to check if the related lists have records.  I have the following situation:

User-added imageI need to check the Account Object to see if the related Object "Testing Type" has any records in a screen flow and make a decision based on the outcome.  The outcome will be simply be Yes when the related object has a record and No when the related object does not contain any record.

How can this be achieved in a sreen flow.

Thanking you in advance.

Crimbo