• sreenath reddy 21
  • NEWBIE
  • 115 Points
  • Member since 2019

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 6
    Questions
  • 24
    Replies
Hi,
i need to send current case to lightning component and wrote below apex but seems i am not able to send current case record  id to lightning component,any solution
 
public static Case getCaseFromId(Id caseID) { 


    if(caseID == null) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        }
    
     List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];
        
        if(cases.size() == 0) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        } else {
            return cases[0];
        }        

}
cmp file
<aura:attribute name="record" type="case[]"/>

controller file
var action = component.get("c.getCaseFromId");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
          
            var navEvent = $A.get("e.force:navigateToSObject");
             alert("hello there!"+ component.get("v.record",response.getReturnValue())); 
            navEvent.setParams({

               "recordId": component.get("v.record",response.getReturnValue())

            });
            navEvent.fire();

Problem is alert shows "undefined" in browser that means something is wrong,any suggestions

Fiona

public class TestTriggerss {
    
     for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
     {
            System.debug(cp.ContactId);
            System.debug(cp.Pricebook2Id);
     }
}
 
Hi all,
I need to save some data in salesforce from OpenID connect response.
How to save that details in my salesforce org 

Thanks 
Hi all,
my requirement is pass data from account to opportunity. I am using visualforce pages.
1. url = '/006/e?ent=Opportunity&nooverride=1&+Amount='AnnualRevenue;
Above url working file for classic.

2.url = '/lightning/o/Opportunity/new?recordTypeId='+rtype+'nooverride=true&defaultFieldValues=Amount='+AnnualRevenue;

It is also working fine and giving expected results.

But my problem is when comment 2nd url, first one only succesfully in classic. In lightning it is not opening.

When comment 1st url, run second url it is always go to lightning.
I want when user is in classic it opens classic page, when user is in lightning it opens lightning page. 

Thanks.
 

Hi all,This is the question asked in interview, how to solve it, please help me

User-added image
By using  lwc, I am creating website, when i enter details and click on submit button it is saving results to the custom objects, when i click submit button multiple times it is saving record multiple times, how to prevent this i need only 1 time click on submit and record saved to org 
@AuraEnabled(cacheable=true)
    public static List<Benefit_Tab__mdt> getBenefitData() {
        List<Benefit_Tab__mdt> benefitTab;
        try {
                if (Benefit_Tab__mdt.sObjectType.getDescribe().isAccessible()) {
                    benefitTab = [Select Masterlabel,DeveloperName,Tab_Description__c,Category__c,
                                    Order__c,CSS_Class__c,Journey_Steps__c
                                    from Benefit_Tab__mdt
                                    where Category__c = 'International'
                                    order by Order__c];
                }
                return benefitTab;
        } catch (QueryException e) {
            throw new AuraHandledException(e.getMessage());
        }
    }

Can any one please help me to write test class for custom meta data class 
https://user-provisioning--mydev.my.salesforce.com/services/data/v49.0/query?jb =SELECT +Id+Name+End_Date__c+Is_JF_Active__c+Is_Chat_User__c+Is_CRM_Content_User__c+Is_Debug_Mode_Enabled__c+Is_Flow_User__c+Is_Knowledge_User__c+Is_Marketing_User__c+Is_Offline_User__c+Is_Sales_Anywhere_User__c+Is_Service_Cloud_User__c+Job_Function_Type__c+Profile__c+Profile_Id__c+Profile_UserType__c+Role__c+Role_Id__c+Salesforce_Licence_for_profile__c+Secondary_JobFunction__c+Secondary_Job_Function__c+Start_Date__c +FROM +Job_Function__c

I am getting   "message": "A query string has to be specified",
        "errorCode": "MALFORMED_QUERY"  this error, please help me to solve the above problem
// Assigning Contact as MMM
public class CaseHandler {
public void populateCaseContactOnInsertFromQuickAction(list<Case> newCaseList) {
  try{
    User userObject = [SELECT id, contact__c FROM user WHERE id=: Userinfo.getUserId() limit 1];
     
    if (userObject.contact__c!='' || userObject.Contact__c!=null) {
      for (Case caseVar : newCaseList) {
        if (caseVar.CaseFromMMMQuickAction__c == true) {
          caseVar.ContactId = userObject.contact__c;
        }
      }
    }
    }catch(Exception e){System.debug('Contact Id exception '+e.getMessage());}
  }
}


Here is the test class :

    @isTest
    private static void populateCaseContactOnInsertFromQuickActionTest()
    {
        try{
            Test.startTest();
            //User user = new User();
            User userObject = [SELECT id, contact__c FROM user WHERE id=: Userinfo.getUserId() limit 1];
            
            Contact con = new Contact();
            con.firstName = 'Test006';
            con.lastName= 'RSN';
            INSERT con;
            
            List<case> newCaseList = new List<Case>();
            Case caseObj = new Case(
                Status = 'Working',
                Origin = 'Phone',
               ContactId = userObject.contact__c);
            
            newCaseList.add(caseObj);
            insert newCaseList;
            
          
            
            if (userObject.contact__c!='' || userObject.Contact__c!=null) {
                for (Case caseVar : newCaseList) {
                    if (caseVar.CaseFromMDMQuickAction__c == true) {
                        caseVar.ContactId = userObject.contact__c;
                    }
                }
            }
            
          //  caseObj = [select id, casenumber from case where id = : caseObj.id];
          //  System.debug('case number' + caseObj.casenumber);
            
            CaseHandler caller = new CaseHandler();
            caller.populateCaseContactOnInsertFromQuickAction(newCaseList);
            
            Test.stopTest(); 
        }Catch(Exception exceptionObject){
            System.debug('Exception occurred : CaseTriggerTest2-->' + exceptionObject.getMessage()+' Stack trace=' + exceptionObject.getStackTraceString()); 
        }   
        
    }


IT is not covering these lines  from class:

caseVar.ContactId = userObject.contact__c;
     
    catch(Exception e){System.debug('Contact Id exception '+e.getMessage());}

  // END


Hi all,This is the question asked in interview, how to solve it, please help me

User-added image
Hi,
i need to send current case to lightning component and wrote below apex but seems i am not able to send current case record  id to lightning component,any solution
 
public static Case getCaseFromId(Id caseID) { 


    if(caseID == null) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        }
    
     List<Case> cases = [ SELECT Id, Subject, Description, Status from CASE where ID = :caseID ];
        
        if(cases.size() == 0) {
            return [SELECT ID, Subject, Description, STATUS from Case LIMIT 1];
        } else {
            return cases[0];
        }        

}
cmp file
<aura:attribute name="record" type="case[]"/>

controller file
var action = component.get("c.getCaseFromId");
    action.setCallback(this, function(response){
        var state = response.getState();
        if (state === "SUCCESS") {
          
            var navEvent = $A.get("e.force:navigateToSObject");
             alert("hello there!"+ component.get("v.record",response.getReturnValue())); 
            navEvent.setParams({

               "recordId": component.get("v.record",response.getReturnValue())

            });
            navEvent.fire();

Problem is alert shows "undefined" in browser that means something is wrong,any suggestions

Fiona
trigger sendEmailToContactWhenfileIsCreated on ContentDocumentLink (after insert) {
   set<id> conDocId=new set<id>();
   for(contentDocumentLink cond:Trigger.new){
    if(cond.linkedEntityId!=null ){
        conDocId.add(cond.linkedEntityId);
   }
}
list<Messaging.SingleEmailMessage> emailList = new list<Messaging.SingleEmailMessage>();
    list<contact> conlist=[select id ,email from contact where id in:conDocId];
for(contentDocumentLink cond:Trigger.new){
    for(contact c:conlist){
        contentversion cv=[select title,versionData from contentversion where id=:cond.contentdocumentId ];
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        list<string> toaddress=new list<string>();
        toaddress.add(c.Email);
        semail.setToaddresses(toaddress);
        semail.setsubject('Email Attachment');
        semail.setPlaintextbody('This is first email attachment');
        semail.settargetobjectId(c.id);
        emailList.add(semail);
        Messaging.EmailFileAttachment efa=new Messaging.EmailFileAttachment();
        efa.setFilename(cv.Title[0]);
        efa.setbody(cv.versionData[0]);

        efa.setFileattachment(new  Messaging.EmailFileAttachment[]{efa});
    }
      }
      Messaging.sendEmail(emailList);
}
I am getting error in above bold line , how to setFilename &setbody  Help here Thank You.
Hi Developer Community,

I am currently working on a task and It requires LWC,
So my problem is , how can i write aura:handler method in LWC

for example:

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

This above example need to be written in LWC,

Can u please help me with this problem

Thanks in Advance

 

 

Hi wonderful Community

I need help with a test class for a trigger, only at 47% !!

Here is the Trigger

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Trigger CreatingAutoRecords on Opportunity (After Insert, After Update)
{
    
    List<MRR__c> MRRRecordsFinalListToInsert = New List<MRR__c>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate)
    {
        For(Opportunity opp : Trigger.New)
        {
            If(Opportunity.Contract_Period_Months__c != null)
            {
                List<MRR__c> fetchingAlreadyExixtsedRecords = [Select Id FROM MRR__c WHERE Opportunity__c =:opp.Id];
                
                If(fetchingAlreadyExixtsedRecords.IsEmpty())
                {
                    // We are only creating a records when there is no MRR__c records exixts.
                    For(Integer I = 1; I <= opp.Contract_Period_Months__c;I++)
                    
                        {
                        MRR__c crd = New MRR__c();
                        
                        crd.Opportunity__c = opp.Id;
                        crd.Name       = 'Month' + I;
                        crd.MRR_Amount__c = opp.MRR_Amount__c;
                        crd.MRR_Date__c = opp.Contract_Start_Date__c.addMonths(I);
                        
                        MRRRecordsFinalListToInsert.add(crd);
                    }
                }
                
            }
            
            try{
                If(!MRRRecordsFinalListToInsert.IsEmpty()){
                    insert MRRRecordsFinalListToInsert;
                }
            }
            Catch(Exception e){
                System.debug('The thrown exception for CreatingAutoRecords is:: ' + e.getMessage());
            }
        }
    }
    
    
}

And this is the Test Class

@isTest
private with sharing class CreatingAutoRecordsTest {

static testMethod void MyTestCreatingAutoRecords()
{
test.starttest(); 

    
    List<MRR__c> MRRRecordsFinalListToInsert = New List<MRR__c>();
    
    
    
    
      
   MRR__c crd = New MRR__c();
    crd.Opportunity__c =  '0062C00000AVFEwQAP';
    crd.Name = 'Testing';
    
    crd.MRR_Amount__c = 110;   
    
      MRRRecordsFinalListToInsert.add(crd);
                        
                        
     insert MRRRecordsFinalListToInsert;
    
    
    
    
    
     Database.SaveResult str = database.insert(crd , False);

        System.assertEquals(True, str.isSuccess());
     
   test.stoptest();  
    

}
}


Any help would he highly appreciated to get it to pass at least

 
I am trying to show stage picklist values of opportunity object through lwc but iit shows error unlnown exception when i deploy code to org

here is my code
<template>
    <div class="side-box">
        <template if:true={StageValues.data}>
           
            <lightning-combobox value={value} label="Opportunity Stage" onchange={handleChange} options={stageValues.data.values}
                name="progress"> </lightning-combobox>
            </template>
    </div>
    
</template>

import OPPORTUNITY_OBJECT from '@salesforce/schema/Opportunity';
import { getPicklistValues } from 'lightning/uiObjectInfoapi';
import Stage from '@salesforce/schema/Opportunity.StageName';
import { getObjectInfo } from 'lightning/uiObjectInfoapi';
import { wire } from 'lwc';
export default class LwcPicklistOppor extends LightningElement {
    @wire(getObjectInfo, { objectApiName : Opportunity_OBJECT})
    opportunityinfo;
    @wire(getPicklistValues,
        {
            recordTypeId: '$opportunityinfo.data.defaultRecordTypeId',
            fieldApiName: Stage
        }
    )
    StageValues;
}
 
If a user doesn’t have Profile CRUD permissions, but given OWD public read/write. Does user will have the permissions on record? If not why.
How can I also cover the catch block?

TriggerHandlerClass with highlighted code(catch block) that is not covered by Test Class:
public class PaymentOrderTriggerHandler {  
    public static void updatePaymentContactInformation(List<Payment_Order__c> paymentOrderList){
        for(Payment_Order__c paymentOrder : paymentOrderList){
            if(paymentOrder.Account__c != Null){
                //Getting particular account id
                ID accountId = paymentOrder.Account__c;
                
                //Updating value to Payment Order from Account with above account id as reference
                try{
                    paymentOrder.Payee_Name__c = [SELECT Name FROM Account WHERE Id = :accountId].Name;
                    paymentOrder.Phone_No__c = [SELECT Phone FROM Account WHERE Id = :accountId].Phone;
                    paymentOrder.Address_Street_1__c = [SELECT BillingStreet FROM Account WHERE Id = :accountId].BillingStreet;
                    paymentOrder.Address_Street_2__c = [SELECT ShippingStreet FROM Account WHERE Id = :accountId].ShippingStreet;
                    paymentOrder.Zip__c = [SELECT ShippingPostalCode FROM Account WHERE Id = :accountId].ShippingPostalCode;
                    paymentOrder.State__c = [SELECT ShippingState FROM Account WHERE Id = :accountId].ShippingState;
                    paymentOrder.Country__c = [SELECT ShippingCountry FROM Account WHERE Id = :accountId].ShippingCountry;
                } catch(Exception error){
                    error.getMessage();
                }
                
            }
        }
    }
    
    public static void insertAccountContactInformation(List<Payment_Order__c> paymentOrderList){
        List<Account> accountList = new List<Account>();
        for(Payment_Order__c paymentOrder : paymentOrderList){
            if(paymentOrder.Account__c == null){
                //Creating new record in Account with field values from Payment Order
                Account newAccount = new Account(Name = paymentOrder.Payee_Name__c, Phone = paymentOrder.Phone_No__c,
                                                 BillingStreet = paymentOrder.Address_Street_1__c,
                                                 ShippingStreet = paymentOrder.Address_Street_2__c,
                                                 ShippingPostalCode = paymentOrder.Zip__c,
                                                 ShippingState = paymentOrder.State__c,
                                                 ShippingCountry = paymentOrder.Country__c);
                accountList.add(newAccount);
            }
        }
        //Inserting created account record
        try{
            insert accountList;
        }catch(Exception error){
            error.getMessage();
        }
        
        //Tagging created account with corresponding Payment Order
        for(Account account : accountList){
            for(Payment_Order__c paymentOrder : paymentOrderList){
                if(paymentOrder.Payee_Name__c == account.Name && paymentOrder.Phone_No__c == account.Phone &&
                                         paymentOrder.Address_Street_1__c == account.BillingStreet &&
                                         paymentOrder.Address_Street_2__c == account.ShippingStreet &&
                                         paymentOrder.Zip__c == account.ShippingPostalCode &&
                                         paymentOrder.State__c == account.ShippingState &&
                                         paymentOrder.Country__c == account.ShippingCountry)
                {
                    paymentOrder.Account__c = account.Id;
                }  
            }
        }
    }
    
    public static void searchAndCreateAccount(List<Payment_Order__c> paymentOrderList){
        boolean found = false;
        List<Account> accountList = new List<Account>();
        for(Payment_Order__c paymentOrder : paymentOrderList){
            for(Account account : [SELECT Name, Phone, BillingStreet, ShippingStreet,
                                   ShippingPostalCode, ShippingState, ShippingCountry FROM Account]){
                                       
                                       if(paymentOrder.Payee_Name__c == account.Name && paymentOrder.Phone_No__c == account.Phone &&
                                          paymentOrder.Address_Street_1__c == account.BillingStreet &&
                                          paymentOrder.Address_Street_2__c == account.ShippingStreet &&
                                          paymentOrder.Zip__c == account.ShippingPostalCode &&
                                          paymentOrder.State__c == account.ShippingState &&
                                          paymentOrder.Country__c == account.ShippingCountry)
                                       {
                                              found = true;
                                              paymentOrder.Account__c = account.id;
                                       }
            }
            if(!found){
                //Need to reuse - code available above
                Account newAccount = new Account(Name = paymentOrder.Payee_Name__c, Phone = paymentOrder.Phone_No__c,
                                             BillingStreet = paymentOrder.Address_Street_1__c,
                                             ShippingStreet = paymentOrder.Address_Street_2__c,
                                             ShippingPostalCode = paymentOrder.Zip__c,
                                             ShippingState = paymentOrder.State__c,
                                             ShippingCountry = paymentOrder.Country__c);
                accountList.add(newAccount);
            }
        }
        //Inserting created account record
        try{
            insert accountList;
        }catch(Exception error){
            error.getMessage();
        }
        
        //Tagging created account with corresponding Payment Order
        for(Account account : accountList){
            for(Payment_Order__c paymentOrder : paymentOrderList){
                if(paymentOrder.Payee_Name__c == account.Name && paymentOrder.Phone_No__c == account.Phone &&
                                         paymentOrder.Address_Street_1__c == account.BillingStreet &&
                                         paymentOrder.Address_Street_2__c == account.ShippingStreet &&
                                         paymentOrder.Zip__c == account.ShippingPostalCode &&
                                         paymentOrder.State__c == account.ShippingState &&
                                         paymentOrder.Country__c == account.ShippingCountry)
                {
                    paymentOrder.Account__c = account.Id;
                }  
            }
        }
    }
    
    public static void updateStatusAndOwner(List<Payment_Order__c> paymentOrderList){
        for(Payment_Order__c paymentOrder : paymentOrderList){
            if(paymentOrder.Payment_Amount__c > 2000){
                paymentOrder.Status__c = 'Pending Approval';
                ID queueId = [SELECT Queue.Id FROM queuesobject WHERE queue.name='Payment Order Pending Approval'].Queue.Id;
                paymentOrder.OwnerId = queueId;
            }
        }
    }
}

Test Class:
@isTest
public class PaymentOrderTriggerHandlerTest {
    @isTest public static void testUpdatePaymentContactInformationCheck(){
        //Creating account
        Account account = new Account(Name = 'Test Account', Phone = '1234567890', BillingStreet = 'Test Billing Street',
                                      ShippingStreet = 'Test Shipping Street', ShippingPostalCode = '625014', ShippingState = 'Test State',
                                      ShippingCountry = 'Test country');
        insert account;
        
        //Creating Payment Order with above account as lookup
        Payment_Order__c paymentOrder = new Payment_Order__c(Account__c = account.Id);
        insert paymentOrder;
        
        Test.startTest();
        //Getting all test data
        String paymentOrderName = [SELECT Payee_Name__c FROM Payment_Order__c WHERE Account__c = :account.Id].Payee_Name__c;
        String paymentOrderPhone = [SELECT Phone_No__c FROM Payment_Order__c WHERE Account__c = :account.Id].Phone_No__c;
        String paymentOrderStreet1 = [SELECT Address_Street_1__c FROM Payment_Order__c WHERE Account__c = :account.Id].Address_Street_1__c;
        String paymentOrderStreet2 = [SELECT Address_Street_2__c FROM Payment_Order__c WHERE Account__c = :account.Id].Address_Street_2__c;
        String paymentOrderZip = [SELECT Zip__c FROM Payment_Order__c WHERE Account__c = :account.Id].Zip__c;
        String paymentOrderState = [SELECT State__c FROM Payment_Order__c WHERE Account__c = :account.Id].State__c;
        String paymentOrderCountry = [SELECT Country__c FROM Payment_Order__c WHERE Account__c = :account.Id].Country__c;
        
        System.assertEquals(account.Name, paymentOrderName);
        System.assertEquals(account.Phone, paymentOrderPhone);
        System.assertEquals(account.BillingStreet, paymentOrderStreet1);
        System.assertEquals(account.ShippingStreet, paymentOrderStreet2);
        System.assertEquals(account.ShippingPostalCode, paymentOrderZip);
        System.assertEquals(account.ShippingState, paymentOrderState);
        System.assertEquals(account.ShippingCountry, paymentOrderCountry);
        Test.stopTest();
    }
    
    @isTest public static void testInsertAccountContactInformationCheck(){
        //Creating Payment Order without lookup account
        Payment_Order__c paymentOrder = new Payment_Order__c(Payee_Name__c = 'Test Payment Order', Phone_No__c = '9876543210', 
                                                             Address_Street_1__c = 'Test Street 1', Address_Street_2__c = 'Test Street 2',
                                                             Zip__c = '625014', State__c = 'Test State', Country__c = 'Test Country');
        insert paymentOrder;
        
        //Getting Id, all data of account created by trigger
        ID accountID = [SELECT Account__c FROM Payment_Order__c WHERE Id = :paymentOrder.Id].Account__c;
        String accountName = [SELECT Name FROM Account WHERE Id = :accountId].Name;
        String accountPhone = [SELECT Phone FROM Account WHERE Id = :accountId].Phone;
        String accountBillingStreet = [SELECT BillingStreet FROM Account WHERE Id = :accountId].BillingStreet;
        String accountShippingStreet = [SELECT ShippingStreet FROM Account WHERE Id = :accountId].ShippingStreet;
        String accountZip = [SELECT ShippingPostalCode FROM Account WHERE Id = :accountId].ShippingPostalCode;
        String accountState = [SELECT ShippingState FROM Account WHERE Id = :accountId].ShippingState;
        String accountCountry = [SELECT ShippingCountry FROM Account WHERE Id = :accountId].ShippingCountry;
        
        Test.startTest();
        System.assertEquals(paymentOrder.Payee_Name__c, accountName);
        System.assertEquals(paymentOrder.Phone_No__c, accountPhone);
        System.assertEquals(paymentOrder.Address_Street_1__c, accountBillingStreet);
        System.assertEquals(paymentOrder.Address_Street_2__c, accountShippingStreet);
        System.assertEquals(paymentOrder.Zip__c, accountZip);
        System.assertEquals(paymentOrder.State__c, accountState);
        System.assertEquals(paymentOrder.Country__c, accountCountry);
        Test.stopTest();
    }
    
    @isTest public static void testSearchAndCreateAccountCheck(){
        //Creating Account
        Account account = new Account(Name = 'Test Account', Phone = '1234567890', BillingStreet = 'Test Billing Street',
                                      ShippingStreet = 'Test Shipping Street', ShippingPostalCode = '625014', ShippingState = 'Test State',
                                      ShippingCountry = 'Test country');
        insert account;
        
        //creating Payment Order
        Payment_Order__c paymentOrder = new Payment_Order__c(Payee_Name__c = 'Test Payment Order', Phone_No__c = '9876543210', 
                                                             Address_Street_1__c = 'Test Street 1', Address_Street_2__c = 'Test Street 2',
                                                             Zip__c = '625014', State__c = 'Test State', Country__c = 'Test Country');
        insert paymentOrder;
        
        //updating payment order to match above account data
        paymentOrder.Payee_Name__c = 'Test Account';
        paymentOrder.Phone_No__c = '1234567890';
        paymentOrder.Address_Street_1__c = 'Test Billing Street';
        paymentOrder.Address_Street_2__c = 'Test Shipping Street';
        paymentOrder.Zip__c = '625014';
        paymentOrder.State__c = 'Test State';
        paymentOrder.Country__c = 'Test Country';
        update paymentOrder;
        
        //getting id of account associated with payment order
        ID paymentOrderAccountId = [SELECT Account__c FROM Payment_Order__c WHERE Id = :paymentOrder.Id].Account__c;
                
        Test.startTest();
        System.assertEquals(account.Id, paymentOrderAccountId);
        
        //updating payment order to not match above account data
        paymentOrder.Phone_No__c = '7777777777';
        update paymentOrder;
        
        //getting updated account lookup id
        paymentOrderAccountId = [SELECT Account__c FROM Payment_Order__c WHERE Id = :paymentOrder.Id].Account__c;
        
        System.assertNotEquals(account.Id, paymentOrderAccountId);
        Test.stopTest();
    }
    
    @isTest public static void testUpdateStatusAndOwnerCheck(){
        //Creating Payment Order with payment amount greater than 2000
        Payment_Order__c paymentOrder = new Payment_Order__c(Payment_Amount__c = 2001);
        insert paymentOrder;
        
        //Getting status of payment order
        String status = [SELECT Status__c FROM Payment_Order__c WHERE Id = :paymentOrder.Id].Status__c;
        
        //getting Queue Id
        ID queueId = [SELECT Queue.Id FROM queuesobject WHERE queue.name='Payment Order Pending Approval'].Queue.Id;
        ID paymentOrderOwnerId = [Select OwnerId FROM Payment_Order__c WHERE Id = :paymentOrder.Id].OwnerId;
        
        Test.startTest();
        System.assertEquals('Pending Approval', status);
        System.assertEquals(queueId, paymentOrderOwnerId);
        Test.stopTest();
    }
}

 
Hi All,

I am getting the following error when I try to delete the object. It was the Master object for a Master Detail relationship. I had converted it to a lookup and have deleted all the references from classes, triggers, and also erased the deleted lookup fields. Please share some input on how this can be resolved. Note: Profile of logged in user is Sys Admin as well.

"Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
"
 

Hi all-

Beginning developer that has been running my head into the wall with this trigger for a while now.  I feel like I am missing something obvious but I don't know where it is.

I have reciently implemented Campaign Influence for my organization.  (for those of you who have not used Campaign Influence - it is related to the Opportunity and Contact Roles.  When a contact role is related to an opportunity, the Campaign influence will pull in the Campaigns related to the contact so they are automatically associated to the campaign.)

I have a requirement that all Campaigns related to a contact must be split equally.  I've tried various ways to pull the Query of related campaign influences, but have found that when I attempt to do a bulk upload, the trigger will combine campaigns two different opps, then divide by the total.

(ie. Opp 1 has 3 related campaign influence and opp 2 has 3 related campaign influence.  Instead of attributing 33% influence to each, I end up with 17%).

 

The below trigger works, but I understand that the trigger should not be in the loop and I would like to improve it.

Thank you!

trigger UpdateOppPrimaryCampaign on Opportunity (after update) {
    	
    	for(Opportunity o : trigger.new)  {
            List<String> oppListId = new List<String>();
        	system.debug('First for loop runs');
        	oppListId.add(o.Id);
			system.debug('oppListId = '+oppListId);
            List<CampaignInfluence> relatedCampaignInfuence = [SELECT Id, CampaignId, Influence, OpportunityId FROM CampaignInfluence WHERE OpportunityId IN :oppListId]; 
        	List<CampaignInfluence> campaignInfluenceListUpdate = new List<CampaignInfluence>();
        	    system.debug('relatedCampaignInfuence = '+relatedCampaignInfuence);
        	
            for(campaignInfluence c : relatedCampaignInfuence){        
            	Decimal numCampaign = relatedCampaignInfuence.size();
            		system.debug ('numCampaign = ' + numCampaign);
           		Decimal percentCampaign =  100 / numCampaign;
            		system.debug ('percentCampaign = '+ percentCampaign);
                 c.Influence = percentCampaign;
            	system.debug('c.Influence = '+ c.Influence);
           	     c.Influenced__c = percentCampaign;
            	campaignInfluenceListUpdate.add(c);
            	system.debug('campaignInfluenceListUpdate = ' + campaignInfluenceListUpdate);
                }
        system.debug('update campaignInfluenceListUpdate EXECUTES');
        Database.SaveResult[] results = Database.update(campaignInfluenceListUpdate, false);
            }

}
 

 

 

 

i merge below  fields,but not receive in email
Hii,{!Contact.Name}
Your Order has been proceed
Your order detail is below.
Product Name:{!Product2.Name}
Product Code:{!Product2.code}
Unit Price:{!OpportunityLineItem.UnitPrice}
List Price:{!OpportunityLineItem.ListPrice}
Discount:{!OpportunityLineItem.Discount}
Thanks
{!Contact.Name}


User-added image
I have added the user as Opportunity Team member. Does the user above the role hietarchy of that team member get the access to that Opportunity ? Please help.
Hi everyone,
I need to change background color of the row onclick on it in lightning datatable or HTML table. I am trying it in Lightning web component but I can't find any solution. 

public class TestTriggerss {
    
     for(Opportunity cp:[Select (Select Id from OpportunityContactRoles ), (SELECT product2.name from OpportunityLineItems) from Opportunity where id=0065g000006qGQZAA2])
     {
            System.debug(cp.ContactId);
            System.debug(cp.Pricebook2Id);
     }
}
 
Hi,
From process builder getting record id and pass that in to apex.

User-added image
Apex class to update the record:

public class BacktoQuantum
{
     @InvocableMethod(label='getdata' description='Get data from saltedge')
  public static void toquantum(List<String> ids)
    {
       BacktoQuantum.fromdata(ids);
       //System.debug('callback');
      
  }
   @future(callout=true)
    public static void fromdata(List<String> ids)
   {
         Http http = new Http();
            HttpRequest request = new HttpRequest();
            request.setEndpoint('http://ussd.apmuyea.software.com/CustomerAdd_SaltEdge_CallBack.aspx');
            request.setMethod('GET');
            //request.setHeader('Accept','application/json');
            request.setHeader('Content-Type', 'text/html; charset=utf-8');
            request.setBody('{"data": {Saltedge Data }}');
       
            HttpResponse responseg = http.send(request);  
            System.debug(responseg.getBody());
        String ac = responseg.getBody(); //Return JSON data
      List<Loan_Application__c> app =  [Select Amount__c,Rate__c,Term_Months__c from Loan_Application__c where Id=:ids];
       if(!app.isEmpty())
       {
                // app[0];
// To update the JSON data in the first record in the list
       }
        //Loan_Application__c app =  new Loan_Application__c();
       //app.SaltedgeData__c = ac;
       //System.debug('sample json' +app);
         } 
}

The above apex code return a JSON data, I need to store that JSON data in salesforce field called Saltedge__c.
I'm stuck in the update.

can anyone help to me update the record?

Thanks.

Hello,

I have certain cases that have been approved/waiting for approval. I want them to be shown on the home page. For that i have create a LWC Component and if the status is pending for approval a clock kind of icon has to be shown beside the case number and if it is approved a approved icon has to be shown. 

I was trying to check the status value of the case using the '.then(result => '  from JS and update two booleans one for pending for approval and another boolean for approved basing on the status.  but it says undefined.  Below is the code.

 .then(result => {
            this.pageSize = 0;
            this.pageCurrent = 0;
            if (result.length > 0) {
                this.allCases = result;
               // console.log('the sub status',result);
            var data = result;
            console.log('the data is',data);
            if(data.length > 0){
                var length = data.length;
                console.log('the length is ',length);
                var substatusvalue = data.Sub_Status__c;
                console.log('the sub status value is ',substatusvalue);
                if(substatusvalue === 'Pending - Int Approval')
                    pendingApproval = true;
                if(substatusvalue === 'Approved')
                    Approved = true;
            
            }
                console.log('it is coming here?');

The console log are coming clearly for everything. But for  this log,  the value is coming up as undefined.  If i can get this value i can use for the boolean check, i can update the boolean and pass to if true in the Template in HTML and can show the icons.

 console.log('the sub status value is ',substatusvalue);

 

Can Anyone help please?. Or is My approach wrong?

 

Thanks,
Ajay.

 

 

 

  • May 16, 2020
  • Like
  • 0
I am new for Integration , Please help me  How to establish a connection One Org to another Org by using Rest API Oauth 2 and Consumer Id and consumer Secret .

Could you please give me sample code ......       

Thanks in advance
  • January 04, 2017
  • Like
  • 0
We changed the list price of a product, and we don't want to enable sales people to still use the old price.
We dont allow changing the sales price (Profile permission) but this protects only creation of new opportunities.
If a user clones a previous record, the old prices remain.
How can I fix this?