• SFDC pv
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 27
    Replies
It says variable doesn't exists ac 

trigger ConOnAccInsert on Account (After insert) {
    List<Account> ListofaccsUpd = new List<Account>();
    List<Contact> listOfcons = new List<Contact>();
    Set<Id> accIds = new Set<ID>();
    for (Account acc : trigger.new) {
            Contact conObj = new contact(firstname = 'acc.name',lastname = 'John',AccountId = acc.Id);
            accIds.add(conObj.AccountId);
            system.debug('id'+accIds);
            listOfcons.add(conObj);
    }
    if(listOfcons.size()>0) insert listOfcons;
    Map<Id,Account> mapOfIDwithAcc = new Map<Id,Account>([Select id ,Name from Account where id =: accIds]);
    List<Account> listOfAcc = new List<Account>();

    if(listOfcons.size()>0){
        for(contact c : listOfcons) {
            if(mapOfIDwithAcc.containsKey(c.AccountId))
            Account ac = new Account();
            ac = mapOfIDwithAcc.get(c.AccountId);
            ac.Client_Contact__c = c.Id;
            ListofaccsUpd.add(ac);
        }
        if(ListofaccsUpd.size()>0) update ListofaccsUpd;    
    }  
If the case status is changed to "waiting for Customer" need to send an email alert after 1 day. Problem here is after the status is changed to waiting for customer user has been left the organization who is the owner of that case so Process builder Schedule action is not triggering its in Paused Interview.. Customer's are not accepting to freeze users for certain days till schedule action is completed.

So what i did as a workaround is i have created a formula field called No of days  = NOW() -Status changed date. It will capture the no of days and referred this field in Process builder -Immediate criteria . Say for eg if No of days is 1 send an email alert to Customer. But its not working any suggestion pls..

Entry screenConditions Criteria
 
I have custom code written for Automatic lead conversion am invoking the class from the Process builder if Data Quality Score is 100 . In the same process builder if the below Criteria Satisfies am creating a case. 
User-added image
I have checked the option "Do you want to execute the actions only when specified changes are made to the record?"

If i include IsConverted as True in the Process builder Criteria its not creating case if i exclude that IsConverted field its creating case. Can someone tell what is the mistake here with Isconverted field.


 
My controller :
public class CreateContractController {
    
    public static void CreateContract(list<Proposal__C> listOfProp,Map<Id, Proposal__C> propOldMap) {
        Id OBSContractRecTypeId = Schema.SObjectType.Contract__c.getRecordTypeInfosByDeveloperName().get('OBS_Signature_Required_By_Customer').getRecordTypeId();
        
        System.debug('value of Proposal :' +listOfProp);
        List<Contract__c> contrList = new List<Contract__c>();
        Set<Id> propId = new Set<Id>();
        
        for(Proposal__c pr : listOfProp){
            propId.add(pr.Id);
            System.debug('PropId'+propId);
        }
        for(Proposal__c prop : [SELECT Id,Name,Account__c,Parent_Contract_ID__c,Previous_Contract_ID__c,Commercial_TC__c,Domestic_Annual_Share__c,International_Annual_Share__c,Opportunity__c,Contact__c,Account__r.OBS_Corporate_Identifier__c,
                                OBS_Annual_Expenditure__c,Status__c,Valid_From_Date__c,Valid_To_Date__c,Standard__c,Additional_Change_Details__c,Deal_Type__c,MCA_Routes_Annual_Share__c,EK_Stock__c,Group_Booking__c,
                                Agent_Name__c,Agent_Fax__c,Agent_Email__c,Agent_Address__c,OBS_Club_Discount__c,Forecast_Group_Booking_Expenditure__c,Group_Travel_Discount__c,Group_Travel_Offer__c,
                                OBS_Club_Join_Discount_Offer__c,OBS_Club_Discount_Offer__c,TMC_Code__c,Type__c,Proposal_Start_Date__c,Proposal_End_Date__c,Opportunity__r.Owner.Country,Opportunity__r.Type,Opportunity__r.Sub_Type_Level_1__c,Opportunity__r.Sub_Type_Level_2__c,Opportunity__r.Category__c                                            
                                FROM Proposal__c where Id =:propId AND Type__c = 'OBS' AND Status__c = 'Approved']) {
                                    
                                    list<Contract__c> existingContractList = [SELECT Id,Status__c,Proposal__c FROM Contract__c where Proposal__c =: propId AND Type__c = 'OBS'];
                                    system.debug('Existing contract list'+existingContractList);
                                    //Validate the contract exists scenario
                              /*     if(!existingContractList.isEmpty()){
                                        for(Contract__c eachContract : existingContractList){
                                            if(eachContract.Status__c != 'Rejected – Legal' && eachContract.Status__c != 'Rejected - Customer'){
                                                System.debug('Inside existing if');
                                                propNewMap.get(eachContract.Proposal__c).addError('Please note Contract already exists for this Proposal');
                                            }
                                        }
                                    }    */
                                    
                                    
                                   if (prop.Status__c == 'Approved' && prop.Status__c != propOldMap.get(prop.Id).Status__c)
                                    {
                                        System.debug('prop value :'+prop);                                    
                                        Contract__c createContract = new Contract__c();
                                        createContract.Name = prop.Name;
                                        createContract.Account__c = prop.Account__c;
                                        createContract.Parent_Contract__c = prop.Parent_Contract_ID__c;
                                        createContract.PreviousContract__c = prop.Previous_Contract_ID__c;
                                        createContract.Commercial_TC__c = prop.Commercial_TC__c;
                                        createContract.Contact__c = prop.Contact__c;
                                        createContract.Domestic_Annual_Share__c = prop.Domestic_Annual_Share__c;
                                        createContract.International_Annual_Share__c = prop.International_Annual_Share__c;
                                        createContract.Opportunity__c = prop.Opportunity__c;
                                        createContract.OBS_Annual_Expenditure__c = prop.OBS_Annual_Expenditure__c;
                                        createContract.Proposal__c = prop.Id;
                                        createContract.Type__c = prop.Type__c;
                                        createContract.Eligible_for_EK_ticket_stock__c = prop.EK_Stock__c;
                                        createContract.Group_Booking__c = prop.Group_Booking__c;
                                        createContract.Standard__c = prop.Standard__c;
                                        createContract.Additional_Change_Details__c = prop.Additional_Change_Details__c;
                                        createContract.Status__c = 'Signature Required by Customer';
                                        createContract.Deal_Type__c = prop.Deal_Type__c;
                                        createContract.MCA_Routes_Annual_Share__c = prop.MCA_Routes_Annual_Share__c;
                                        createContract.Agent_Name__c = prop.Agent_Name__c;
                                        createContract.Agent_Fax__c = prop.Agent_Fax__c;
                                        createContract.Agent_Email__c = prop.Agent_Email__c;
                                        createContract.Agent_Address__c = prop.Agent_Address__c;
                                        createContract.OBS_Club_Discount__c = prop.OBS_Club_Discount__c;
                                        createContract.OBS_Club_Join_Discount_Offer__c = prop.OBS_Club_Join_Discount_Offer__c;
                                        createContract.OBS_Club_Discount_Offer__c = prop.OBS_Club_Discount_Offer__c;
                                        createContract.TMC_Code__c = prop.TMC_Code__c;
                                        createContract.contract_Start_Date__c = prop.Proposal_Start_Date__c;
                                        createContract.contract_End_Date__c = prop.Proposal_End_Date__c; 
                                        createContract.Forecast_Group_Booking_Expenditure__c = prop.Forecast_Group_Booking_Expenditure__c;
                                        createContract.RecordTypeId = OBSContractRecTypeId;
                                        contrList.add(createContract);
                                        system.debug('Contract list'+contrList);
                                    }
                                }
        try {
            if(!contrList.isEmpty()){  
                insert contrList;
            }
        }
        catch(DMLException e){
            System.debug(e.getMessage());
        }
        // Contract Fare Discount creation done here
        list<Contract_Discount_List__c> createCFDiscountList = new list<Contract_Discount_List__c>();
        System.debug('prop id:'+propid); 
        for(Discount_List__c eachPFD : [SELECT Id, Proposal__c,FareStructure__c,Approval_Comment_Pricing__c, Approval_Comment_NAM__c,Comment__c, Discount__c,Route_Origin__c,Route_Destination__c,Fare_Combination__c FROM Discount_List__c WHERE Proposal__r.Active__c = True AND Proposal__r.Status__c = 'Approved' AND Proposal__r.Type__c = 'OBS' AND Proposal__c = :propId]){
            System.debug('Discount list :'+eachPFD);                        
            Contract_Discount_List__c contFareDisc = new Contract_Discount_List__c();
            contFareDisc.Approval_Comment_NAM__c = eachPFD.Approval_Comment_NAM__c;
            contFareDisc.Approval_Comment_Pricing__c = eachPFD.Approval_Comment_Pricing__c;
            contFareDisc.FareStructure__c = eachPFD.FareStructure__c;
            contFareDisc.Comment__c = eachPFD.Comment__c;
            contFareDisc.Contract__c = contrList[0].id;
            contFareDisc.Discount__c = eachPFD.Discount__c;
            contFareDisc.Fare_Combination__c = eachPFD.Fare_Combination__c;
            contFareDisc.Route_Origin__c    = eachPFD.Route_Origin__c;
            contFareDisc.Route_Destination__c   = eachPFD.Route_Destination__c;
            createCFDiscountList.add(contFareDisc);
            system.debug('createCFDiscountList'+createCFDiscountList);
        }    
        try {
            if(!createCFDiscountList.isEmpty()){        
                insert createCFDiscountList;            
            }
        }
        catch(DMLException e){
            System.debug(e.getMessage());
        }
    }
}

Test class:-
@isTest
public class CreateContractController_Test {

    @isTest 
    public static void CreateContractTest() {
        
        String accRTId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer Account').getRecordTypeId();
        String OppRTId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('Business_and_Government').getRecordTypeId();
        Map<Id, Proposal__C> propOldMap = new Map<Id, Proposal__C>();
       // Map<Id, Proposal__C> propNewMap = new Map<Id, Proposal__C>(); 

        //Create Account
        Account testacc = new Account(Name = 'Sample', Active__c = true, Aquire__c = true, Type = 'Customer Account', 
                                      RecordTypeId = accRTId, Migrated__c = false, 
                                      Estimated_Total_Air_Travel_Spend__c = 0, Manual_Revenue_Update__c = false,
                                      Agency__c = 'N', Dealing_Flag__c = 'N', Aquire_Override__c = 'N');
        insert testacc;
        //Create Contact
        Contact testcon = new Contact(FirstName='Bob',LastName='Test',AccountId=testacc.id,Function__c = 'IT',Business_Types__c = 'Agency',Email = 'abc@test.com');
        insert testcon;        
        //Create Oppotunity
        Opportunity validOpp = new Opportunity(Name = 'Opp2'+testacc.Name , AccountId = testacc.Id,Proposed_Market_Share__c = 70,Proposed_International_Market_Share__c = 50,
                                               Amount = 500000, Category__c = 'OBS', CloseDate = Date.Today(),Proposed_MCA_Routes_Market_Share__c = 90,
                                               StageName = 'Qualify');
        insert validOpp;
        
        //Create Proposal
        List<Proposal__c> propList = new List<Proposal__c>();
        Proposal__c propErr = new Proposal__c(Name = 'Proposal0', Account__c = validOpp.AccountId, Opportunity__c = validOpp.Id,
                                              Active__c = True, Type__c = 'OBS', International_Annual_Share__c = 70,
                                              Domestic_Annual_Share__c = 90, Frequent_Flyer_Status_Upgrade__c = 'No',
                                              MCA_Routes_Annual_Share__c = 70, Valid_From_Date__c = Date.Today(),
                                              OBS_Annual_Expenditure__c = 500000, OBS_Club_Discount__c = 'No', Status__c = 'Draft'
                                             );
           propList.add(propErr);

        if(!propList.isEmpty())
        insert propList;
        for(Proposal__C  prop : propList) {
                     propOldMap.put(prop.Id,prop);   
                    system.debug('Old Map value of Prop'+propOldMap);
        }
        Test.startTest();
        propList[0].Status__c = 'Approved';
        Update propList;
        Test.stopTest();
        system.debug('Proposal list'+propList[0] );
        system.debug('Old Map value of Prop -1:'+propOldMap);
        //Create Contract
        Contract__c contr = new Contract__c(Name = propList[0].Name, Account__c = propList[0].Account__c, Opportunity__c = propList[0].Opportunity__c, Proposal__c = propList[0].Id,
                                            Active__c = true, Type__c = 'OBS', International_Annual_Share__c = 70,
                                            Domestic_Annual_Share__c = 90, Frequent_Flyer_Status_Upgrade__c = 'No', Contracted__c = false,
                                            MCA_Routes_Annual_Share__c = 70, Contract_Start_Date__c = Date.Today(), Contract_End_Date__c = Date.Today(),
                                            OBS_Annual_Expenditure__c = 500000, OBS_Club_Discount__c = 'No', Status__c = 'Signature Required by Customer'                                              
                                           );
        insert contr;         

        Fare_Structure__c fs = new Fare_Structure__c(Name = 'J', Active__c = true, Cabin__c = 'Business', 
                                                     Category__c = 'Mainline', Market__c = 'Australia', 
                                                     ProductCode__c = 'DOM-0001', OBS_Published_Airfare__c = 'JBUS',
                                                     Segment__c = 'Domestic'
                                                    );
        insert fs;

        // create a disc list
        Discount_List__c disc = new Discount_List__c(FareStructure__c = fs.Id, Proposal__c = propList[0].Id, 
                                                         OBS_Published_Airfare__c = fs.OBS_Published_Airfare__c, 
                                                         Fare_Combination__c = 'Mainline - H in B deal', Segment__c = fs.Segment__c,
                                                         Category__c = fs.Category__c, Network__c = fs.Network__c, 
                                                         Market__c = fs.Market__c, Cabin__c = fs.Cabin__c, 
                                                         Proposal_Type__c = propList[0].Type__c, Discount__c = 40
                                                        );

            insert disc;
         
        
        Contract_Discount_List__c contrFD = new Contract_Discount_List__c(FareStructure__c = fs.id,Contract__c=contr.id,Discount__c = 40,Comment__c = 'test');

        insert contrFD; 
        
        System.debug('Map value' +propOldMap );
        system.debug('Proplist'+propList);
    //    Test.StartTest();
            //Invoke the controller methods
               CreateContractController.CreateContract(propList,propOldMap);
    //    Test.StopTest(); 
    }
    
}

Class.CreateContractController.CreateContract: line 102, column 1
Class.CreateContractController_Test.CreateContractTest: line 85, column 1

Its not coming inside if

Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.CalloutException: The callout couldn't access the endpoint. You might not have the required permissions, or the named credential "ProjectService" might not exist.
Close errors
Please let me know whats wrong. 
Package.xml

<?xml version="1.0" encoding="UTF-8"?>  
<Package xmlns="http://soap.sforce.com/2006/04/metadata">  
   <types>  
     <members>Archival_Data__b</members>  
     <name>CustomObject</name>  
   </types>  
   <types>  
     <members>Archival_Data</members>  
     <name>PermissionSet</name>  
   </types>  
   <version>41.0</version>  
</Package>    

I stored Archival_Data__b.Object in the object folder and Archival_Data.permissionSet in the permissionsets folder. 
Apex class:-
@AuraEnabled
    public static String updatecase(String caseId, String accountId, String results)
    {       
       
        Set<String> loffinstr = new Set<String>();
        List<XXX> DFFlist= new list<XXX>([SELECT Number__c FROM XXX WHERE Case__c =:CaseId ]);
        for(XXX finfo : DFFlist ){
            loffinstr.add(finfo.Number__c);
        }
        List<XXX>  lstpss= new List<XXX>();
        List<Object> fieldList = (List<Object>)JSON.deserializeUntyped(results);
        System.debug('ffmap'+results);
        
        if(!fieldList.isEmpty()) {
            for(Object fld : fieldList){    
                Map<String,Object> data = (Map<String,Object>)fld;
                system.debug(data.get('key1'));
                if(!loffinstr.contains(String.valueOf(data.get('key2'))))  {    
                    XXX FFrecs = new XXX();
                    FFrecs.Case__c = caseId;
                    FFrecs.Account__c = accountId;
                    FFrecs.Name = String.valueOf(data.get('key0'));
                    lstpss.add(FFrecs);     
                } 
            }
        }
        insert  lstpss;
    }

    Helper class :-

        //call apex class method
        var action = component.get('c.updatecase');
            //var objList = component.get("v.selectedpss");
            var myMap = component.get("v.selectedpss");
            console.log('type 2-' + typeof myMap);
            console.log('ValuesOfmyMap' +JSON.stringify(myMap));
            action.setParams({
                "caseId": component.get("v.CaseId"),
                "accountId" : component.get("v.AccountId"),
                "results" : JSON.stringify(myMap)
            });

Especially tell me how to pass the parameter(caseid,accountid,results) which is in Helper to Apex test class
        <aura:iteration items="{!v.freqFlyerList}" var="wrap" indexVar="idx">
                                    <tr>
                                        <th>
                                            <label class="slds-checkbox">
                                                <ui:inputCheckbox aura:id="test" value="" text="{!idx}" />
                                                <span class="slds-checkbox--faux" />
                                                <span class="slds-form-element__label"></span>
                                            </label>
                                        </th>
                                        <th scope="row">
                                            <div class="slds-truncate" title="{!wrap.key1}">{!wrap.key1}</div>
                                        </th>
                                        <td class="slds-truncate">
                                            {!wrap.key2}
                                        </td>
                                        <td class="slds-truncate">
                                            {!wrap.key3}
                                        </td> 
                                        <td class="slds-truncate">
                                            {!wrap.key4}
                                        </td>
                                        <td class="slds-truncate">
                                            {!wrap.key5}
                                        </td> 
                                        <td class="slds-truncate">
                                  <lightning:select aura:id="ReqPicklist" onchange="{!c.ReqTypechange}">
                                              <option value="">Please select</option>
                                              <option value="val1">val1</option>
                                              <option value="val2">val1</option>
                                              <option value="val3">val1</option>
                                </lightning:select>
                                    </td>
                                         <td class="slds-truncate">
                                           <lightning:select aura:id="TierPicklist" onchange="{!c.UpgTierchange}">
                                              <option value="">Please select</option>
                                              <option value="val1">val1</option>
                                              <option value="val2">val2</option>
                                              <option value="val3">val3</option>
                                           </lightning:select>
                                        </td>    
                                    </tr>
                                </aura:iteration>
Onchange ctrlr:-

ReqTypechange : function(component, event, helper) {
        var pickReqTypeval = component.find("ReqPicklist").get("v.value");
        console.log('ReqPicklist-'+ReqPicklist);
    },
    
    UpgTierchange : function(component, event, helper) {
        var pickUpgTierval = component.find("TierPicklist").get("v.value");
        console.log('Tierval-'+Tierval);
    }, 
                                <aura:iteration items="{!v.freqFlyerList}" var="wrap" indexVar="idx">
                                    <tr>
                                        <th>
                                            <label class="slds-checkbox">
                                                <ui:inputCheckbox aura:id="checkFreqFlyer" value="" text="{!idx}" />
                                                <span class="slds-checkbox--faux" />
                                                <span class="slds-form-element__label"></span>
                                            </label>
                                        </th>
                                        <th scope="row">
                                            <div class="slds-truncate" title="{!wrap.key1}">{!wrap.key1}</div>
                                        </th>
                                        <td class="slds-truncate">
                                            {!wrap.key2}
                                        </td>
                                        <td class="slds-truncate">
                                            {!wrap.key3}
                                        </td> 
                                        <td class="slds-truncate">
                                            {!wrap.key4}
                                        </td>
                                        <td class="slds-truncate">
                                            {!wrap.key5}
                                        </td> 
                                        <td class="slds-truncate">
                                  <lightning:select aura:id="ReqPicklist" onchange="{!c.ReqTypechange}">
                                              <option value="">Please select</option>
                                              <option value="val1">val1</option>
                                              <option value="val2">val1</option>
                                              <option value="val3">val1</option>
                                </lightning:select>
                                    </td>
                                         <td class="slds-truncate">
                                           <lightning:select aura:id="UpgradeTierPicklist" onchange="{!c.UpgTierchange}">
                                              <option value="">Please select</option>
                                              <option value="val1">val1</option>
                                              <option value="val2">val2</option>
                                              <option value="val3">val3</option>
                                           </lightning:select>
                                        </td>    
                                    </tr>
                                </aura:iteration>
Onchange ctrlr:-

ReqTypechange : function(component, event, helper) {
        var pickReqTypeval = component.find("RequestTypePicklist").get("v.value");
        console.log('reqtypevalue-'+pickReqTypeval);
    },
    
    UpgTierchange : function(component, event, helper) {
        var pickUpgTierval = component.find("UpgradeTierPicklist").get("v.value");
        console.log('pickUpgTierval-'+pickUpgTierval);
    }, 

This is working for only one rows if i have more than rows its not allowing me to select the values its throwing error " $ReqTypechange [component.find(...).get is not a function]"
@AuraEnabled
    public static String insertinfo(String caseId, String accountId, List<String> results)
    {
        system.debug('ffmap'+results);    
        list<objectWrap> myWrap = (list<objectWrap>)results;    //Getting error here . Also ffmap is not coming in the valid format 
 }
ffmap log :- ({key=123, value={key1=KEITH W PETERSON, key2=123, key3=null, key4=Bronze, key5=31-Jan-2019}}, {key=456, value={key1=JOYCE P WEST, key2=456, key3=xdkzwhzorm@uaowz.qca, key4=Bronze, key5=31-Jul-2018}})

From helper i am getting proper json format whereas in the apex ctrlr am getting the result in valid format
My helper class :- 

CreateHelper: function(component, event) {
        //call apex class method
        var action = component.getinsertinfo
            var myMap = component.get("v.selectednos");
            console.log('Mymapvalue' + myMap);
            action.setParams({
                "caseId": component.get("v.CaseId"),
                "accountId" : component.get("v.AccountId"),
                "results" : myMap
            });

log:-
Mymapvalue'  :-   [{"key":"123","value":{"key1":"KEITH W PETERSON","key2":"123","key3":null,"key4":"Bronze","key5":"31-Jan-2019"}},{"key":"456","value":{"key1":"JOYCE P WEST","key2":"456","key3":"xdkzwhzorm@uaowz.qca","key4":"Bronze","key5":"31-Jul-2018"}}]
                                        <td class="slds-truncate">
                                            <select>
                                              <option value="">Please select</option>
                                              <option value="xxx">xxx</option>
                                              <option value="yyy">yyy</option>
                                              <option value="zzz">zzz</option>
                                            </select>
                                        </td>
    @auraEnabled
    Public static List<string> invokeWebServiceString ssnumber) {
        String [] arrayOfResponsestrings = new List<String>();

        for(String num : ssnumber.split(',')){          
            ResponseWrapper APIResponse = InvokeAPI.invokeRespAPI(num);
            arrayOfResponsestrings.add(JSON.serialize(APIResponse ));
            System.debug('arrayOfResponsestrings :'+arrayOfResponsestrings);
        }
        for(Integer i=0 ;i<arrayOfResponsestrings.size() ; i++) {
        }
        return arrayOfResponsestrings;
    } 
  • September 30, 2018
  • Like
  • 0
It says variable doesn't exists ac 

trigger ConOnAccInsert on Account (After insert) {
    List<Account> ListofaccsUpd = new List<Account>();
    List<Contact> listOfcons = new List<Contact>();
    Set<Id> accIds = new Set<ID>();
    for (Account acc : trigger.new) {
            Contact conObj = new contact(firstname = 'acc.name',lastname = 'John',AccountId = acc.Id);
            accIds.add(conObj.AccountId);
            system.debug('id'+accIds);
            listOfcons.add(conObj);
    }
    if(listOfcons.size()>0) insert listOfcons;
    Map<Id,Account> mapOfIDwithAcc = new Map<Id,Account>([Select id ,Name from Account where id =: accIds]);
    List<Account> listOfAcc = new List<Account>();

    if(listOfcons.size()>0){
        for(contact c : listOfcons) {
            if(mapOfIDwithAcc.containsKey(c.AccountId))
            Account ac = new Account();
            ac = mapOfIDwithAcc.get(c.AccountId);
            ac.Client_Contact__c = c.Id;
            ListofaccsUpd.add(ac);
        }
        if(ListofaccsUpd.size()>0) update ListofaccsUpd;    
    }  
I have custom code written for Automatic lead conversion am invoking the class from the Process builder if Data Quality Score is 100 . In the same process builder if the below Criteria Satisfies am creating a case. 
User-added image
I have checked the option "Do you want to execute the actions only when specified changes are made to the record?"

If i include IsConverted as True in the Process builder Criteria its not creating case if i exclude that IsConverted field its creating case. Can someone tell what is the mistake here with Isconverted field.


 
My controller :
public class CreateContractController {
    
    public static void CreateContract(list<Proposal__C> listOfProp,Map<Id, Proposal__C> propOldMap) {
        Id OBSContractRecTypeId = Schema.SObjectType.Contract__c.getRecordTypeInfosByDeveloperName().get('OBS_Signature_Required_By_Customer').getRecordTypeId();
        
        System.debug('value of Proposal :' +listOfProp);
        List<Contract__c> contrList = new List<Contract__c>();
        Set<Id> propId = new Set<Id>();
        
        for(Proposal__c pr : listOfProp){
            propId.add(pr.Id);
            System.debug('PropId'+propId);
        }
        for(Proposal__c prop : [SELECT Id,Name,Account__c,Parent_Contract_ID__c,Previous_Contract_ID__c,Commercial_TC__c,Domestic_Annual_Share__c,International_Annual_Share__c,Opportunity__c,Contact__c,Account__r.OBS_Corporate_Identifier__c,
                                OBS_Annual_Expenditure__c,Status__c,Valid_From_Date__c,Valid_To_Date__c,Standard__c,Additional_Change_Details__c,Deal_Type__c,MCA_Routes_Annual_Share__c,EK_Stock__c,Group_Booking__c,
                                Agent_Name__c,Agent_Fax__c,Agent_Email__c,Agent_Address__c,OBS_Club_Discount__c,Forecast_Group_Booking_Expenditure__c,Group_Travel_Discount__c,Group_Travel_Offer__c,
                                OBS_Club_Join_Discount_Offer__c,OBS_Club_Discount_Offer__c,TMC_Code__c,Type__c,Proposal_Start_Date__c,Proposal_End_Date__c,Opportunity__r.Owner.Country,Opportunity__r.Type,Opportunity__r.Sub_Type_Level_1__c,Opportunity__r.Sub_Type_Level_2__c,Opportunity__r.Category__c                                            
                                FROM Proposal__c where Id =:propId AND Type__c = 'OBS' AND Status__c = 'Approved']) {
                                    
                                    list<Contract__c> existingContractList = [SELECT Id,Status__c,Proposal__c FROM Contract__c where Proposal__c =: propId AND Type__c = 'OBS'];
                                    system.debug('Existing contract list'+existingContractList);
                                    //Validate the contract exists scenario
                              /*     if(!existingContractList.isEmpty()){
                                        for(Contract__c eachContract : existingContractList){
                                            if(eachContract.Status__c != 'Rejected – Legal' && eachContract.Status__c != 'Rejected - Customer'){
                                                System.debug('Inside existing if');
                                                propNewMap.get(eachContract.Proposal__c).addError('Please note Contract already exists for this Proposal');
                                            }
                                        }
                                    }    */
                                    
                                    
                                   if (prop.Status__c == 'Approved' && prop.Status__c != propOldMap.get(prop.Id).Status__c)
                                    {
                                        System.debug('prop value :'+prop);                                    
                                        Contract__c createContract = new Contract__c();
                                        createContract.Name = prop.Name;
                                        createContract.Account__c = prop.Account__c;
                                        createContract.Parent_Contract__c = prop.Parent_Contract_ID__c;
                                        createContract.PreviousContract__c = prop.Previous_Contract_ID__c;
                                        createContract.Commercial_TC__c = prop.Commercial_TC__c;
                                        createContract.Contact__c = prop.Contact__c;
                                        createContract.Domestic_Annual_Share__c = prop.Domestic_Annual_Share__c;
                                        createContract.International_Annual_Share__c = prop.International_Annual_Share__c;
                                        createContract.Opportunity__c = prop.Opportunity__c;
                                        createContract.OBS_Annual_Expenditure__c = prop.OBS_Annual_Expenditure__c;
                                        createContract.Proposal__c = prop.Id;
                                        createContract.Type__c = prop.Type__c;
                                        createContract.Eligible_for_EK_ticket_stock__c = prop.EK_Stock__c;
                                        createContract.Group_Booking__c = prop.Group_Booking__c;
                                        createContract.Standard__c = prop.Standard__c;
                                        createContract.Additional_Change_Details__c = prop.Additional_Change_Details__c;
                                        createContract.Status__c = 'Signature Required by Customer';
                                        createContract.Deal_Type__c = prop.Deal_Type__c;
                                        createContract.MCA_Routes_Annual_Share__c = prop.MCA_Routes_Annual_Share__c;
                                        createContract.Agent_Name__c = prop.Agent_Name__c;
                                        createContract.Agent_Fax__c = prop.Agent_Fax__c;
                                        createContract.Agent_Email__c = prop.Agent_Email__c;
                                        createContract.Agent_Address__c = prop.Agent_Address__c;
                                        createContract.OBS_Club_Discount__c = prop.OBS_Club_Discount__c;
                                        createContract.OBS_Club_Join_Discount_Offer__c = prop.OBS_Club_Join_Discount_Offer__c;
                                        createContract.OBS_Club_Discount_Offer__c = prop.OBS_Club_Discount_Offer__c;
                                        createContract.TMC_Code__c = prop.TMC_Code__c;
                                        createContract.contract_Start_Date__c = prop.Proposal_Start_Date__c;
                                        createContract.contract_End_Date__c = prop.Proposal_End_Date__c; 
                                        createContract.Forecast_Group_Booking_Expenditure__c = prop.Forecast_Group_Booking_Expenditure__c;
                                        createContract.RecordTypeId = OBSContractRecTypeId;
                                        contrList.add(createContract);
                                        system.debug('Contract list'+contrList);
                                    }
                                }
        try {
            if(!contrList.isEmpty()){  
                insert contrList;
            }
        }
        catch(DMLException e){
            System.debug(e.getMessage());
        }
        // Contract Fare Discount creation done here
        list<Contract_Discount_List__c> createCFDiscountList = new list<Contract_Discount_List__c>();
        System.debug('prop id:'+propid); 
        for(Discount_List__c eachPFD : [SELECT Id, Proposal__c,FareStructure__c,Approval_Comment_Pricing__c, Approval_Comment_NAM__c,Comment__c, Discount__c,Route_Origin__c,Route_Destination__c,Fare_Combination__c FROM Discount_List__c WHERE Proposal__r.Active__c = True AND Proposal__r.Status__c = 'Approved' AND Proposal__r.Type__c = 'OBS' AND Proposal__c = :propId]){
            System.debug('Discount list :'+eachPFD);                        
            Contract_Discount_List__c contFareDisc = new Contract_Discount_List__c();
            contFareDisc.Approval_Comment_NAM__c = eachPFD.Approval_Comment_NAM__c;
            contFareDisc.Approval_Comment_Pricing__c = eachPFD.Approval_Comment_Pricing__c;
            contFareDisc.FareStructure__c = eachPFD.FareStructure__c;
            contFareDisc.Comment__c = eachPFD.Comment__c;
            contFareDisc.Contract__c = contrList[0].id;
            contFareDisc.Discount__c = eachPFD.Discount__c;
            contFareDisc.Fare_Combination__c = eachPFD.Fare_Combination__c;
            contFareDisc.Route_Origin__c    = eachPFD.Route_Origin__c;
            contFareDisc.Route_Destination__c   = eachPFD.Route_Destination__c;
            createCFDiscountList.add(contFareDisc);
            system.debug('createCFDiscountList'+createCFDiscountList);
        }    
        try {
            if(!createCFDiscountList.isEmpty()){        
                insert createCFDiscountList;            
            }
        }
        catch(DMLException e){
            System.debug(e.getMessage());
        }
    }
}

Test class:-
@isTest
public class CreateContractController_Test {

    @isTest 
    public static void CreateContractTest() {
        
        String accRTId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Customer Account').getRecordTypeId();
        String OppRTId = Schema.SObjectType.Opportunity.getRecordTypeInfosByDeveloperName().get('Business_and_Government').getRecordTypeId();
        Map<Id, Proposal__C> propOldMap = new Map<Id, Proposal__C>();
       // Map<Id, Proposal__C> propNewMap = new Map<Id, Proposal__C>(); 

        //Create Account
        Account testacc = new Account(Name = 'Sample', Active__c = true, Aquire__c = true, Type = 'Customer Account', 
                                      RecordTypeId = accRTId, Migrated__c = false, 
                                      Estimated_Total_Air_Travel_Spend__c = 0, Manual_Revenue_Update__c = false,
                                      Agency__c = 'N', Dealing_Flag__c = 'N', Aquire_Override__c = 'N');
        insert testacc;
        //Create Contact
        Contact testcon = new Contact(FirstName='Bob',LastName='Test',AccountId=testacc.id,Function__c = 'IT',Business_Types__c = 'Agency',Email = 'abc@test.com');
        insert testcon;        
        //Create Oppotunity
        Opportunity validOpp = new Opportunity(Name = 'Opp2'+testacc.Name , AccountId = testacc.Id,Proposed_Market_Share__c = 70,Proposed_International_Market_Share__c = 50,
                                               Amount = 500000, Category__c = 'OBS', CloseDate = Date.Today(),Proposed_MCA_Routes_Market_Share__c = 90,
                                               StageName = 'Qualify');
        insert validOpp;
        
        //Create Proposal
        List<Proposal__c> propList = new List<Proposal__c>();
        Proposal__c propErr = new Proposal__c(Name = 'Proposal0', Account__c = validOpp.AccountId, Opportunity__c = validOpp.Id,
                                              Active__c = True, Type__c = 'OBS', International_Annual_Share__c = 70,
                                              Domestic_Annual_Share__c = 90, Frequent_Flyer_Status_Upgrade__c = 'No',
                                              MCA_Routes_Annual_Share__c = 70, Valid_From_Date__c = Date.Today(),
                                              OBS_Annual_Expenditure__c = 500000, OBS_Club_Discount__c = 'No', Status__c = 'Draft'
                                             );
           propList.add(propErr);

        if(!propList.isEmpty())
        insert propList;
        for(Proposal__C  prop : propList) {
                     propOldMap.put(prop.Id,prop);   
                    system.debug('Old Map value of Prop'+propOldMap);
        }
        Test.startTest();
        propList[0].Status__c = 'Approved';
        Update propList;
        Test.stopTest();
        system.debug('Proposal list'+propList[0] );
        system.debug('Old Map value of Prop -1:'+propOldMap);
        //Create Contract
        Contract__c contr = new Contract__c(Name = propList[0].Name, Account__c = propList[0].Account__c, Opportunity__c = propList[0].Opportunity__c, Proposal__c = propList[0].Id,
                                            Active__c = true, Type__c = 'OBS', International_Annual_Share__c = 70,
                                            Domestic_Annual_Share__c = 90, Frequent_Flyer_Status_Upgrade__c = 'No', Contracted__c = false,
                                            MCA_Routes_Annual_Share__c = 70, Contract_Start_Date__c = Date.Today(), Contract_End_Date__c = Date.Today(),
                                            OBS_Annual_Expenditure__c = 500000, OBS_Club_Discount__c = 'No', Status__c = 'Signature Required by Customer'                                              
                                           );
        insert contr;         

        Fare_Structure__c fs = new Fare_Structure__c(Name = 'J', Active__c = true, Cabin__c = 'Business', 
                                                     Category__c = 'Mainline', Market__c = 'Australia', 
                                                     ProductCode__c = 'DOM-0001', OBS_Published_Airfare__c = 'JBUS',
                                                     Segment__c = 'Domestic'
                                                    );
        insert fs;

        // create a disc list
        Discount_List__c disc = new Discount_List__c(FareStructure__c = fs.Id, Proposal__c = propList[0].Id, 
                                                         OBS_Published_Airfare__c = fs.OBS_Published_Airfare__c, 
                                                         Fare_Combination__c = 'Mainline - H in B deal', Segment__c = fs.Segment__c,
                                                         Category__c = fs.Category__c, Network__c = fs.Network__c, 
                                                         Market__c = fs.Market__c, Cabin__c = fs.Cabin__c, 
                                                         Proposal_Type__c = propList[0].Type__c, Discount__c = 40
                                                        );

            insert disc;
         
        
        Contract_Discount_List__c contrFD = new Contract_Discount_List__c(FareStructure__c = fs.id,Contract__c=contr.id,Discount__c = 40,Comment__c = 'test');

        insert contrFD; 
        
        System.debug('Map value' +propOldMap );
        system.debug('Proplist'+propList);
    //    Test.StartTest();
            //Invoke the controller methods
               CreateContractController.CreateContract(propList,propOldMap);
    //    Test.StopTest(); 
    }
    
}

Class.CreateContractController.CreateContract: line 102, column 1
Class.CreateContractController_Test.CreateContractTest: line 85, column 1

Its not coming inside if
@AuraEnabled
    public static String insertinfo(String caseId, String accountId, List<String> results)
    {
        system.debug('ffmap'+results);    
        list<objectWrap> myWrap = (list<objectWrap>)results;    //Getting error here . Also ffmap is not coming in the valid format 
 }
ffmap log :- ({key=123, value={key1=KEITH W PETERSON, key2=123, key3=null, key4=Bronze, key5=31-Jan-2019}}, {key=456, value={key1=JOYCE P WEST, key2=456, key3=xdkzwhzorm@uaowz.qca, key4=Bronze, key5=31-Jul-2018}})

From helper i am getting proper json format whereas in the apex ctrlr am getting the result in valid format
My helper class :- 

CreateHelper: function(component, event) {
        //call apex class method
        var action = component.getinsertinfo
            var myMap = component.get("v.selectednos");
            console.log('Mymapvalue' + myMap);
            action.setParams({
                "caseId": component.get("v.CaseId"),
                "accountId" : component.get("v.AccountId"),
                "results" : myMap
            });

log:-
Mymapvalue'  :-   [{"key":"123","value":{"key1":"KEITH W PETERSON","key2":"123","key3":null,"key4":"Bronze","key5":"31-Jan-2019"}},{"key":"456","value":{"key1":"JOYCE P WEST","key2":"456","key3":"xdkzwhzorm@uaowz.qca","key4":"Bronze","key5":"31-Jul-2018"}}]
                                        <td class="slds-truncate">
                                            <select>
                                              <option value="">Please select</option>
                                              <option value="xxx">xxx</option>
                                              <option value="yyy">yyy</option>
                                              <option value="zzz">zzz</option>
                                            </select>
                                        </td>
    @auraEnabled
    Public static List<string> invokeWebServiceString ssnumber) {
        String [] arrayOfResponsestrings = new List<String>();

        for(String num : ssnumber.split(',')){          
            ResponseWrapper APIResponse = InvokeAPI.invokeRespAPI(num);
            arrayOfResponsestrings.add(JSON.serialize(APIResponse ));
            System.debug('arrayOfResponsestrings :'+arrayOfResponsestrings);
        }
        for(Integer i=0 ;i<arrayOfResponsestrings.size() ; i++) {
        }
        return arrayOfResponsestrings;
    } 
  • September 30, 2018
  • Like
  • 0
If i click on the "New Button" i need to call the child component which is a pop up window. 
This is my component  i will place the below icon on my case page

Parent Component : - 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" controller ="Test_CreateXXController" access="global" >
   
   <aura:attribute name="isOpen" type="boolean" default="false"/>
   <aura:attribute name="recordId" type="String" />  
   <c:Testcomponent  aura:id="child"/>
 <!--  <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> -->
   <div onclick="{!c.doInit}">
        <a class="Fontcolor" href=""><lightning:card iconName="utility:info" title="New Button" /></a>          
    </div> 
<!-- </div> -->    
</aura:component>

Controller:-

({
    doInit: function(component, event, helper) {
        
        console.log('intosearch');
      //helper.Navigate(component, event, helper);      
          var testComponent = component.find('child');
        console.log('childcomponent');
          testComponent.getchildMethod(); 

   } 

})
Child component :- 

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:method name="getchildMethod" action="{!c.doAction}"/
    <aura:attribute name="isOpen" type="boolean" default="True"/>    

This is not working. Please help me out.
  • September 17, 2018
  • Like
  • 0
In my organization we have so many classes ,I am not able to map approiate test class with actual class as their naming convention is different of that of class .
is there any way to find out plz help me.
Thanks in advance for ur help.
Map <List<String>,XXX__c > FFMap = new Map <List<String>,XXX__c> ();
List<Case> Caslist= [SELECT Id,AccountID,Number__c FROM Case  WHERE ID =:CaseId ];
Set<String> xxset = new Set<String>(); 
for (Case cs: Caslist) {
                xxset.add(cs.Number__c);
         }
          List<string> str = new List<string>();
          for (xxx__c xxinfo: [select id,Account__c,Case__c,Number__c from XXX__c where Number__c in :xxset]) { 
              str.add(xxinfo.Number__c);
              xxMap.put(str, xxinfo);
            }
if(Cas.Number__c!=null) {
            for (String num : Cas.Number__c.split(',') )
            {              
                if(num!=''  && !xxMap.containskey(num)) {   // Recieving error here  (Method does not exist or incorrect signature: void containskey(String) from the type Map<List<String>,XXX__c>)
}
}
}

Can someone correct me on what mistake i did in above snippet.