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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 26
    Replies
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
intosearchHelper
Test_ModalSearchComponent.js:16 actionSecureAction: [object Object]{ key: {"namespace":"c"} }
Test_ModalSearchComponent.js:23 ####returnvalueERROR
Test_ModalSearchComponent.js:25 ####parentIdnull
Test_ModalSearchComponent.js:14 intosearchHelper
Test_ModalSearchComponent.js:16 actionSecureAction: [object Object]{ key: {"namespace":"c"} }
Test_ModalSearchComponent.js:23 ####returnvalueERROR
Test_ModalSearchComponent.js:25 ####parentIdnull

Test_ModalSearchComponent:-
<aura:component controller ="Test_xxController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
                      <div style="display:inline-block;margin-right:10px" onclick="{!c.Search}">
                        <lightning:icon iconName="utility:search" size="small" >
                           </lightning:icon>

Controller:-

({
        Search : function(component, event, helper) {
        var action = component.get("c.invokeWebService");
        console.log('action');
        action.setParams({
            "CaseId" : component.get("v.recordId")
        
        });
        action.setCallback(this, function(response) {
        var state = response.getState();
        console.log('####returnvalue'+state);
        var parentId = component.get('v.recordId');
        console.log('####parentId'+response.getReturnValue());
        
        if (state == "SUCCESS") {
                var output = response.getReturnValue();
                component.set("v.response", output);
                console.log(output);
        }   
   });
             $A.enqueueAction(action);
},
})

Apex controller:-

global class Test_xxController {
    
    @AuraEnabled
    @future(callout=true)
    Public static void invokeWebService(String CaseId) {
        
        Map <String,xx_Information__c > FFMap = new Map <String,xx_Information__c> ();   
        
        Map<String, Integer> monthAndMonthNumberMap = new Map<String, Integer>();
        monthAndMonthNumberMap.put('Jan', 1);
        monthAndMonthNumberMap.put('Feb', 2);
        monthAndMonthNumberMap.put('Mar', 3);
        monthAndMonthNumberMap.put('Apr', 4);
        monthAndMonthNumberMap.put('May', 5);
        monthAndMonthNumberMap.put('Jun', 6);
        monthAndMonthNumberMap.put('Jul', 7);
        monthAndMonthNumberMap.put('Aug', 8);
        monthAndMonthNumberMap.put('Sep', 9);
        monthAndMonthNumberMap.put('Oct', 10);
        monthAndMonthNumberMap.put('Nov', 11);
        monthAndMonthNumberMap.put('Dec', 12);
        
        List<Case> Caslist= [SELECT Id,AccountID,xx_Number__c FROM Case  WHERE ID =:CaseId ];
        List<xx_Information__c> listofFF = new List<xx_Information__c>();
        List<xx_Information__c> DFFlist= new list<xx_Information__c>([SELECT xx_Number__c FROM xx_Information__c WHERE Case__c =:CaseId ]);
        
        Set<String> loffinstr = new Set<String>();
        Set<String> Dloffinstr = new Set<String>();
        Set<String> Nloffinstr = new Set<String>();
        Boolean isDuplicate;
        for(xx_Information__c finfo : DFFlist ){
            loffinstr.add(finfo.xx_Number__c);
            Dloffinstr.add(finfo.xx_Number__c);
            
        }
        Case Cas= [SELECT Id,AccountID,xx_Number__c FROM Case  WHERE ID =:CaseId ];
        system.debug('***Case-FF***'+Cas);
 
            for (String num : Cas.xx_Number__c.split(',') )
            {
                system.debug('Numbers'+num);
                if (Nloffinstr.Contains(num)) {
                  //  Isduplicate = true;                
                }
                else {
                    Nloffinstr.add(num);
                }
                
                if(num!='' && !loffinstr.contains(num)){
                    system.debug('insideloop'+num);
                    loffinstr.add(num);
                    xx_ResponseWrapper xxResponse = xx_InvokeAPI.invokexxAPI(num);                 
                    system.debug('$$$xxResponse$$$'+xxResponse);              
                    if(xxResponse != Null){
                        xx_Information__c ff = new xx_Information__c();
                        ff.Name = xxResponse.firstName+' '+xxResponse.lastName;
                        ff.xx_Email__c = xxResponse.email;
                        ff.xx_Number__c = num;
                        ff.Case__c = Cas.ID;
                        ff.Account__c = Cas.AccountId;
                        
                        for(xx_xxResponseWrapper.programDetails  program: xxResponse.programDetails){
                            if(program.ffExpireDate!=null){
                                String myDateStr = program.ffExpireDate;
                                System.debug('$$$ mydateStr: '+ myDateStr);
                                List<String> myDateList = myDateStr.split('-');
                                Integer yearVal = Integer.valueOf(myDateList.get(2));
                                Integer monthVal = monthAndMonthNumberMap.get(myDateList.get(1));
                                Integer dayVal = Integer.valueOf(myDateList.get(0));
                                date mydate = date.newinstance(yearVal,monthVal,dayVal);
                                ff.Freq_Flyer_Expiry_Date__c = mydate;
                                ff.Current_Tier__c = program.tierName;
                            }                         
                        }
                        ff.Request_Type__c = '';
                        ff.Upgrade_Tier_Requested__c = '';                               
                        listofFF.add(ff);
                    }
                }
            }            

        if(listofFF.size()>0) {
            insert listofFF;              
            system.debug('Insertion'+listofFF);    
        }
    }
}
  • September 18, 2018
  • Like
  • 0
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. 
                              string ffdate = program.ffExpireDate;  
                              system.debug('ffexpirydate'+ffdate);
                               date dt = date.parse(ffdate);
                               FF.Expiry_Date__c = dt; 
Getting Error :-   |FATAL_ERROR|System.TypeException: Invalid date: 30-Sep-2018

Log: 
|USER_DEBUG|[49]|DEBUG|ffexpirydate30-Sep-2018 
|FATAL_ERROR|System.TypeException: Invalid date: 30-Sep-2018