• shaik murthujavali
  • NEWBIE
  • 195 Points
  • Member since 2018

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 25
    Replies
I coded my functions on the controller but I realized this is not a best practice to code directly on the controller. I tried transferring them but I get errors. Can somebody help me transfer my codes.

Note I exclude some functions. I already transfered already.
Accountcontroller.js
({
    "doInit": function(component, event, helper) {
        //initializes the component 
        helper.setPagination(component);
        //set data table headers
        component.set('v.columns', [
            { label: 'ACCOUNT NAME', fieldName: 'Name', type: 'text' },
            { label: 'NO. OF CONTACTS', fieldName: 'contacts', type: 'text' }
        ]);
    },
    "selectAccount":function(component,event,helper){
        var row = event.getParam('selectedRows');
        //fire event which shows the related contacts of the account selected
        var appEvent = $A.get("e.c:RelatedContactEvent");
        for(var r in row){
            var accId = row[r].Id;
            appEvent.setParams({
                "accId" : accId
            });
            appEvent.fire();
        }
    },
    "searchQueryChange": function(component, event) {
        var recordToDisply = component.get("v.pageSize");
        var searchKey = component.find("searchKey").get("v.value");
        //create a one-time use instance of the serverQuery action
        var action = component.get("c.searchQuery");
        if(searchKey != '' || searchKey != null){
            //prioritizes first page when searching
            component.set("v.page", 1);
            //dynamic searching
            component.set("v.pages", 1); 
        }
        //call server-side action
        action.setParams({
            "searchKey": searchKey,
            "recordToDisply": recordToDisply
        });
        action.setCallback(this, function(a) {
            let accounts = JSON.parse(a.getReturnValue());
            let accountsWithContacts = [];
            accounts.forEach(item =>{
                let newItem = {};
                             newItem.Name = item.Name;
                             newItem.Id = item.Id;   
                             if(item.Contacts)
            newItem.contacts = item.Contacts.totalSize + '';
            else
                newItem.contacts = '0';
            accountsWithContacts.push(newItem);
            if(searchKey == '' || searchKey == null){
                var page = component.get("v.pageCopy");
                var pages = component.get("v.pagesCopy");
                
                component.set("v.page", page);
                
                component.set("v.pages", pages);
            }
        })
        component.set("v.data", accountsWithContacts);
    });
    //adds the server-side controller action to the queue of actions to be executed
    $A.enqueueAction(action);
    },
    "handleSuccess" : function(component, event, helper) {
        var gotcha = $A.get("$Label.c.AccountCreateSuccess");
        component.set('v.isShowAccountForm', false);
        component.find('notifLib').showToast({
            "variant": "success",
            "title": gotcha
        });
        //refreshes the account table view after creating an account
        $A.get('e.force:refreshView').fire();
        
    },
    "navigate": function(component, event, helper) {
        // this function call on click on the previous page button
        var page = component.get("v.page") || 1;
        // get the previous button label
        var direction = event.getSource().get("v.label");
        // get the select option (drop-down) values.
        var recordToDisply = component.get("v.pageSize");
        // set the current page,(using ternary operator.)
        page = direction === "Previous" ? (page - 1) : (page + 1);
        // call the helper function
        helper.getAccounts(component, page, recordToDisply);
    }
})

ContactController.js.
"onSelectChange": function(component, event, helper) {
        // this function call on the select option change,   
        var page = 1
        var recordToDisply = component.find("recordSize").get("v.value");
        helper.getContacts(component, page, recordToDisply);
    },
   "handleSubmit": function(cmp, event, helper) {
        event.preventDefault();
        var accnt = cmp.get("v.accntId");
        var eventFields = event.getParam("fields");
        eventFields["AccountId"] = accnt;
        cmp.find('contactForm').submit(eventFields);
    },
    "handleSuccess" : function(component, event, helper) {
        var createsuccess = $A.get("$Label.c.ContactCreateSucess");
        component.set('v.isShowContactForm', false);
        component.find('notifLib').showToast({
            "variant": "success",
            "title": createsuccess
        });
        //refreshes the contact table view after creating a contact
        $A.get('e.force:refreshView').fire();
    },  
    "handleRowAction" : function (component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        console.log("ACTION NAME: " + action.name);
       
        switch (action.name) {
            case 'view':
                var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                      "recordId": row.Id,
                      "slideDevName": "details"
                    });
                navEvt.fire();
                break;
               
            case 'delete':
               var doAction = component.get("c.deleteContact");
              
               doAction.setParams({
                    "Id": row.Id
                });
                doAction.setCallback(this,function(response){
                    // store the response return value
                    var resultData = response.getReturnValue();
                    var state = response.getState();
                    var delsuccess = $A.get("$Label.c.ContactDeleteSuccess");
                    var delfail = $A.get("$Label.c.ContactDeleteFail");
                    if (state == "SUCCESS") {
                        if(resultData == true){
                            component.find('notifLib').showToast({                               
                                "variant": "success",
                                "title": delsuccess
                               });
                            $A.get('e.force:refreshView').fire();
                        }else{
                            component.find('notifLib').showToast({
                                "variant": "error",
                                "title": delfail
                               });   
                        }
                    }
                    
                });
                $A.enqueueAction(doAction);
                break;
        }
    },
    "navigate": function(component, event, helper) {
        // this function call on click on the previous page button  
        var page = component.get("v.page") || 1;
        // get the previous button label  
        var direction = event.getSource().get("v.label");
        // get the select option (drop-down) values.  
        var recordToDisply = component.get("v.pageSize");
        // set the current page,(using ternary operator.)  
        if(direction == "Previous"){
            page = (page - 1);
        }else{
            page = (page + 1);
        }
        component.set("v.page", page);
        // call the helper function
        helper.getContacts(component, event, page, recordToDisply);
    },

 
global class CSTeamCountryCaseUpdateBatch implements Database.Batchable<sObject>{
   global Database.QueryLocator start(Database.BatchableContext bc) {
      return Database.getQueryLocator([SELECT ID, Status, LastModifiedDate,LastModifiedById,Last_Modified_By_Previous_Day__c,CS_Team_Country__c,Days_Since_Last_Modified_Date__c FROM Case Where Status !='Closed' AND (CS_Team_Country__c ='United States' OR CS_Team_Country__c ='Canada')]);
    }
    global void execute(Database.BatchableContext bc, List<Case> records){
        system.debug('records--'+records.size());
       List<Case> caseList = new List<Case>();
        for(Case c:records){
            system.debug('test--'+c.Days_Since_Last_Modified_Date__c);
            if(c.Days_Since_Last_Modified_Date__c == null){
                c.Days_Since_Last_Modified_Date__c =0;
            }
            c.Days_Since_Last_Modified_Date__c =c.Days_Since_Last_Modified_Date__c+1;
            if(c.LastModifiedById != system.label.apiuserid){
            c.Last_Modified_By_Previous_Day__c =c.LastModifiedById;
            }
            caseList.add(c);
        }
        system.debug('caseList--'+caseList);
        if(caseList.size()>0){
            update caseList;
        }
        system.debug('caseList--'+caseList);
    }    
    global void finish(Database.BatchableContext bc){
        
    }   
}
I want to change the contact associated with the partner user to another contact, but the contact field is not displayed on the edit screen of the user. Is there no way to change it? Thank you.
  • July 15, 2020
  • Like
  • 0
public class class2 {

 public list<string> lststatename{get;set;}
       
       public list<string> lstrating{get;set;}
       
        public map<string, string>statemap{get;set;} 
        
        
          public list<string>selectedvalues{get;set;}

 public  class2(){
 
 
 
 
 
      string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
       

      map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 

    list<object>  values1= (list<object>)metadatamap.get('data');  
    
     lststatename= new list<string>();
    
    lstrating= new list<string>();
    
         statemap= new map<String, string>(); 
        
        
          for(object parsed : values1){
          
             map<string,object>  values = (map<string,object>)parsed;
          
          string statename = string.valueof(values.get('stateName'));
          
          
          string value = string.valueof(values.get('value'));
          
          
          lststatename.add(statename);
          
          
       
          
          
           statemap.put(statename, value);
}


 }
 
 
 
   public PageReference test(){
   
  
   
   //code to be written 
   
   
   
    return null;
   
   
   
   }
}
 
<apex:page controller="class2">
  
  
  <apex:form >
  
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!lststatename}" var="a">
      <li ><apex:inputCheckbox value="{!statemap[a]}" /><label>{!a}</label></li>
        </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm"/>
   
   
    <apex:outputLabel id="fm">
    
      the selected values are :
    </apex:outputLabel>
  </apex:form>
  
  
</apex:page>

User-added image

onclicking on the test button , the values are to be displayed, how to achieve this functionality ?

Thanks in advance
So I am building a Custom Visualforce page in which I have created a custom object say Student. Now I want to search Students using a search box in a visualforce page so that if I click on a student's name it details gets filled shown in the fields below. 

Although I tried doing it with Lookup field which I set up as Mentor for each student but I want the lookup to show student names instead of the mentors
<apex:page standardController="Student__c"   showHeader="false" >
    
 <h1 style="align: center; font-size:x-large">Student Details</h1>
 
 

<apex:form>
        <apex:inputField value="{!Student__c.Mentor__c}"/>
</apex:form>
    <apex:pageBlock>
        <apex:pageBlockSection>
            <h3>Student Name:</h3>
            <h5>Student Class: </h5> 

        </apex:pageBlockSection>
    </apex:pageBlock>


</apex:page>
Hi everyone,
can any one help on this.Here it is showing the count of record but i want to hide it.Is it possible.
User-added image
Thanks.
Shaik Murthujavali
I'm trying to create a component that shows related activity on the account page. But it's only showing the last object. Any ideas on how to fix this? Also is there a way to add the chatter feed?


public with sharing class CaseActivityController {
    
    public List<Task> lstTask {get;set;}
    
    public CaseActivityController(ApexPages.StandardController std) 
    {
        Id AccountId = std.getId(); //Get AccountId
        
        //Query on Case
        Map<Id, Case> mapIdToCase = new Map<Id,Case>([Select Id from Case where AccountId =: AccountId]);
        
        //Query on Case Activity 
        lstTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToCase.keyset() ORDER BY ActivityDate]);
        
        //Query on Contact
        Map<Id, Contact> mapIdToContact = new Map<Id,Contact>([Select Id from Contact where AccountId =: AccountId]);
        
        //Query on Contact Activity 
        2ndTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToContact.keyset() ORDER BY ActivityDate]);
         
        //Query on Opportunity
        Map<Id, Opportunity> mapIdToOpportunity = new Map<Id,Opportunity>([Select Id from Opportunity where AccountId =: AccountId]);
        
        //Query on Opportunity Activity 
        3rdTask = new List<Task>([SELECT CallType,Status,Subject,WhatId,ActivityDate,Description FROM Task WHERE WhatId IN: mapIdToOpportunity.keyset() ORDER BY ActivityDate]);
    }
}
I coded my functions on the controller but I realized this is not a best practice to code directly on the controller. I tried transferring them but I get errors. Can somebody help me transfer my codes.

Note I exclude some functions. I already transfered already.
Accountcontroller.js
({
    "doInit": function(component, event, helper) {
        //initializes the component 
        helper.setPagination(component);
        //set data table headers
        component.set('v.columns', [
            { label: 'ACCOUNT NAME', fieldName: 'Name', type: 'text' },
            { label: 'NO. OF CONTACTS', fieldName: 'contacts', type: 'text' }
        ]);
    },
    "selectAccount":function(component,event,helper){
        var row = event.getParam('selectedRows');
        //fire event which shows the related contacts of the account selected
        var appEvent = $A.get("e.c:RelatedContactEvent");
        for(var r in row){
            var accId = row[r].Id;
            appEvent.setParams({
                "accId" : accId
            });
            appEvent.fire();
        }
    },
    "searchQueryChange": function(component, event) {
        var recordToDisply = component.get("v.pageSize");
        var searchKey = component.find("searchKey").get("v.value");
        //create a one-time use instance of the serverQuery action
        var action = component.get("c.searchQuery");
        if(searchKey != '' || searchKey != null){
            //prioritizes first page when searching
            component.set("v.page", 1);
            //dynamic searching
            component.set("v.pages", 1); 
        }
        //call server-side action
        action.setParams({
            "searchKey": searchKey,
            "recordToDisply": recordToDisply
        });
        action.setCallback(this, function(a) {
            let accounts = JSON.parse(a.getReturnValue());
            let accountsWithContacts = [];
            accounts.forEach(item =>{
                let newItem = {};
                             newItem.Name = item.Name;
                             newItem.Id = item.Id;   
                             if(item.Contacts)
            newItem.contacts = item.Contacts.totalSize + '';
            else
                newItem.contacts = '0';
            accountsWithContacts.push(newItem);
            if(searchKey == '' || searchKey == null){
                var page = component.get("v.pageCopy");
                var pages = component.get("v.pagesCopy");
                
                component.set("v.page", page);
                
                component.set("v.pages", pages);
            }
        })
        component.set("v.data", accountsWithContacts);
    });
    //adds the server-side controller action to the queue of actions to be executed
    $A.enqueueAction(action);
    },
    "handleSuccess" : function(component, event, helper) {
        var gotcha = $A.get("$Label.c.AccountCreateSuccess");
        component.set('v.isShowAccountForm', false);
        component.find('notifLib').showToast({
            "variant": "success",
            "title": gotcha
        });
        //refreshes the account table view after creating an account
        $A.get('e.force:refreshView').fire();
        
    },
    "navigate": function(component, event, helper) {
        // this function call on click on the previous page button
        var page = component.get("v.page") || 1;
        // get the previous button label
        var direction = event.getSource().get("v.label");
        // get the select option (drop-down) values.
        var recordToDisply = component.get("v.pageSize");
        // set the current page,(using ternary operator.)
        page = direction === "Previous" ? (page - 1) : (page + 1);
        // call the helper function
        helper.getAccounts(component, page, recordToDisply);
    }
})

ContactController.js.
"onSelectChange": function(component, event, helper) {
        // this function call on the select option change,   
        var page = 1
        var recordToDisply = component.find("recordSize").get("v.value");
        helper.getContacts(component, page, recordToDisply);
    },
   "handleSubmit": function(cmp, event, helper) {
        event.preventDefault();
        var accnt = cmp.get("v.accntId");
        var eventFields = event.getParam("fields");
        eventFields["AccountId"] = accnt;
        cmp.find('contactForm').submit(eventFields);
    },
    "handleSuccess" : function(component, event, helper) {
        var createsuccess = $A.get("$Label.c.ContactCreateSucess");
        component.set('v.isShowContactForm', false);
        component.find('notifLib').showToast({
            "variant": "success",
            "title": createsuccess
        });
        //refreshes the contact table view after creating a contact
        $A.get('e.force:refreshView').fire();
    },  
    "handleRowAction" : function (component, event, helper) {
        var action = event.getParam('action');
        var row = event.getParam('row');
        console.log("ACTION NAME: " + action.name);
       
        switch (action.name) {
            case 'view':
                var navEvt = $A.get("e.force:navigateToSObject");
                navEvt.setParams({
                      "recordId": row.Id,
                      "slideDevName": "details"
                    });
                navEvt.fire();
                break;
               
            case 'delete':
               var doAction = component.get("c.deleteContact");
              
               doAction.setParams({
                    "Id": row.Id
                });
                doAction.setCallback(this,function(response){
                    // store the response return value
                    var resultData = response.getReturnValue();
                    var state = response.getState();
                    var delsuccess = $A.get("$Label.c.ContactDeleteSuccess");
                    var delfail = $A.get("$Label.c.ContactDeleteFail");
                    if (state == "SUCCESS") {
                        if(resultData == true){
                            component.find('notifLib').showToast({                               
                                "variant": "success",
                                "title": delsuccess
                               });
                            $A.get('e.force:refreshView').fire();
                        }else{
                            component.find('notifLib').showToast({
                                "variant": "error",
                                "title": delfail
                               });   
                        }
                    }
                    
                });
                $A.enqueueAction(doAction);
                break;
        }
    },
    "navigate": function(component, event, helper) {
        // this function call on click on the previous page button  
        var page = component.get("v.page") || 1;
        // get the previous button label  
        var direction = event.getSource().get("v.label");
        // get the select option (drop-down) values.  
        var recordToDisply = component.get("v.pageSize");
        // set the current page,(using ternary operator.)  
        if(direction == "Previous"){
            page = (page - 1);
        }else{
            page = (page + 1);
        }
        component.set("v.page", page);
        // call the helper function
        helper.getContacts(component, event, page, recordToDisply);
    },

 

Hi guys,

I have 2 custom objects (Management and ReportsandDashboards)
I have a field name flat section in management .So i have to count total no. of flat records created in management  by creating a field in 
ReportsandDashboards

I've tried creating a formula field, but not it's not clear to me what the formula should be.
I also tried creating an Apex trigger. However, I couldn't get the select statement to work.

I want a field in ReportsandDashboards that is readonly and counts the number of time the field flat is used in the Management .

Please advice the correct way to approach this :)
Please can someone point me in the right direction as I can't see my errors?
@isTest
private class TicketInAccrual {

  public class TestData {
    public Map<String, RecordType> tirtMap;
    public FX5__Status__c newTicketStatus;
    public FX5__Status__c TicketInAccrualStatus;
    public List<FX5__Catalog_Item__c> ciList;
    public List<FX5__Price_Book_Item__c> pbiList;
    
    public String GetDefaultUOMForRecordType(String rtDeveloperName) {
        if (rtDeveloperName == 'Daily_Personnel' || rtDeveloperName == 'Daily_Equipment')
          return 'Day';
        if (rtDeveloperName == 'Hourly_Equipment' || rtDeveloperName == 'Hourly_Personnel')
          return 'Hour';
        return 'Each';
    }
    
    public void ProvisionTestData(FX_UnitTestHelper.ExproJob_LocalTestData mockData) {
          this.newTicketStatus = new FX5__Status__c(
            Name = 'New Ticket',
            FX5__SObject__c = 'Ticket__c',
            Status_Developer_Name__c = 'New_Ticket');
          this.TicketInAccrualStatus = new FX5__Status__c(
            Name = 'Ticket in Accrual',
            FX5__SObject__c = 'Ticket__c',
            Status_Developer_Name__c = 'Ticket_in_Accrual');
        insert this.newTicketStatus;
        insert this.TicketInAccrualStatus;      
      
      this.tirtMap = new Map<String,RecordType>();
      this.ciList = new List<FX5__Catalog_Item__c>();
      Integer ciCount = 1;
      for (RecordType tirt : [select Id,DeveloperName from RecordType where IsActive=true and SobjectType='FX5__Ticket_Item__c']) {
        this.tirtMap.put(tirt.DeveloperName,tirt);
        this.ciList.add(new FX5__Catalog_Item__c(
          Name = String.valueOf(ciCount) + '-0135',
          FX5__IsArchived__c = false,
          FX5__Description__c = 'Test Item ' + String.valueOf(ciCount),
          EXPRO_SAP_Plant__c = '0135',
          FX5__Sequence_Number__c = ciCount,
          FX5__Ticket_Item_Record_Type__c = tirt.DeveloperName,
          FX5__UOM__c = GetDefaultUOMForRecordType(tirt.DeveloperName)
        ));
        ciCount += 1;
        this.ciList.add(new FX5__Catalog_Item__c(
          Name = String.valueOf(ciCount) + '-0135',
          FX5__IsArchived__c = false,
          FX5__Description__c = 'Test Item ' + String.valueOf(ciCount),
          EXPRO_SAP_Plant__c = '0135',
          FX5__Sequence_Number__c = ciCount,
          FX5__Ticket_Item_Record_Type__c = tirt.DeveloperName,
          FX5__UOM__c = this.GetDefaultUOMForRecordType(tirt.DeveloperName)
        ));
        ciCount += 1;
      }
      insert this.ciList;
      
      Set<Id> ciIdSet = new Set<Id>();
      for (FX5__Catalog_Item__c ci : ciList) {
        insert (new FX5__Price_Book_Item__c(
          FX5__Price_Book__c = mockData.testPriceBook.Id,
          FX5__IsArchived__c = false,
          FX5__Catalog_Item__c = ci.Id,
          FX5__Default_Quantity__c = 0,
          FX5__Price__c = 100));
        ciIdSet.add(ci.Id);
      }
      // We want to fetch the Price Book Items back after insertion so that we get the result of all triggers that fired
      this.pbiList = [
        select 
          Id,FX5__Price_Book__c,FX5__Catalog_Item__c,FX5__IsArchived__c,FX5__Default_Quantity__c,FX5__Price__c,
          FX5__Ticket_Item_Record_Type__c,FX5__Sequence_Number__c,FX5__Catalog_Item__r.FX5__Ticket_Item_Record_Type__c
        from FX5__Price_Book_Item__c where FX5__Catalog_Item__c in :ciIdSet];
    }
  }

    static testMethod void TestTicketItemSequencingForSAP() {
        FX_UnitTestHelper.ExproJob_LocalTestData mockData = new FX_UnitTestHelper.ExproJob_LocalTestData();
        mockData.ProvisionTestData(true);
        TestData testData = new TestData();
        testData.ProvisionTestData(mockData);
         
        List<FX5__Ticket__c> tktList = FX_UnitTestHelper.CreateTickets(mockData.testJob, 2, true);
        FX5__Ticket__c readyForInvTicket = tktList.get(0);
        FX5__Ticket__c newTicket = tktList.get(1);
        
        List<FX5__Ticket_Item__c> testTktItems = new List<FX5__Ticket_Item__c>();
        // Add ticket items to the each mock ticket
        for (FX5__Ticket__c tkt : tktList) {
          for (FX5__Price_Book_Item__c pbi : testData.pbiList) {
            RecordType tiRT = testData.tirtMap.get(pbi.FX5__Catalog_Item__r.FX5__Ticket_Item_Record_Type__c);
            testTktItems.add(new FX5__Ticket_Item__c(
              FX5__Ticket__c = tkt.Id,
              FX5__Price_Book_Item__c = pbi.Id,
              RecordTypeId = tiRT.Id));
          }
        }
        insert testTktItems;
        
        Test.startTest();
        
      newTicket.FX5__Status__c = testData.newTicketStatus.Id;
      TicketInAccrualTicket.FX5__Status__c = testData.TicketinAccrualStatus.Id;
      
      update newTicket;      
      update TicketInAccrualTicket;
        
        Test.stopTest();
        
        List<FX5__Ticket_Item__c> newTicketItems = [select Id,FX5__Ticket__c,EXPRO_SAP_Item_Number__c from FX5__Ticket_Item__c where FX5__Ticket__c = :newTicket.Id];
        // Ensure that Ticket items on the "New Ticket" items did not update EXPRO_SAP_Item_Number__c
        for (FX5__Ticket_Item__c tktItem : newTicketItems) {
          System.assert(tktItem.EXPRO_SAP_Item_Number__c == null, 'Expected null for EXPRO_SAP_Item_Number__c on "New Ticket" Ticket Item.');
        } 
        
        List<FX5__Ticket_Item__c> TicketInAccrualTicketItems = [select Id,FX5__Ticket__c,EXPRO_SAP_Item_Number__c,Record_Type_Sort_Index__c,RecordTypeId from FX5__Ticket_Item__c where FX5__Ticket__c = :TicketInAccrualTicket.Id order by EXPRO_SAP_Item_Number__c];
        System.assert(TicketInAccrualTicketItems.size() > 0);
        for (Integer i=0; i < TicketInAccrualTicketItems.size(); i+=1) {
          FX5__Ticket_Item__c ti = TicketInAccrualTicketItems.get(i);
          System.assertEquals((i+1)*10, ti.EXPRO_SAP_Item_Number__c);
        }
    }
    
    /*
    * This test ensures that a Ticket that does not have a status will not crash the Ticket On After trigger and will not cause any other 
    * unit tests to fail that do not have a status reference. 
     */
    static testMethod void TestInsertTicketWithNullStatus() {
      FX_UnitTestHelper.ExproJob_LocalTestData mockData = new FX_UnitTestHelper.ExproJob_LocalTestData();
        mockData.ProvisionTestData(true);
        
        RecordType ftRT = [select Id,DeveloperName from RecordType where IsActive=true and SobjectType='FX5__Ticket__c' and DeveloperName='Field_Ticket'];
        FX5__Ticket__c t = new FX5__Ticket__c(
          FX5__Job__c = mockData.testJob.Id,
          RecordTypeId = ftRT.Id
        );
        
        Test.startTest();
        insert t;        
        Test.stopTest();
        
        System.assertEquals(1,([select Id from FX5__Ticket__c where FX5__Job__c = :mockData.testJob.Id]).size());
    }
    
}
global class CSTeamCountryCaseUpdateBatch implements Database.Batchable<sObject>{
   global Database.QueryLocator start(Database.BatchableContext bc) {
      return Database.getQueryLocator([SELECT ID, Status, LastModifiedDate,LastModifiedById,Last_Modified_By_Previous_Day__c,CS_Team_Country__c,Days_Since_Last_Modified_Date__c FROM Case Where Status !='Closed' AND (CS_Team_Country__c ='United States' OR CS_Team_Country__c ='Canada')]);
    }
    global void execute(Database.BatchableContext bc, List<Case> records){
        system.debug('records--'+records.size());
       List<Case> caseList = new List<Case>();
        for(Case c:records){
            system.debug('test--'+c.Days_Since_Last_Modified_Date__c);
            if(c.Days_Since_Last_Modified_Date__c == null){
                c.Days_Since_Last_Modified_Date__c =0;
            }
            c.Days_Since_Last_Modified_Date__c =c.Days_Since_Last_Modified_Date__c+1;
            if(c.LastModifiedById != system.label.apiuserid){
            c.Last_Modified_By_Previous_Day__c =c.LastModifiedById;
            }
            caseList.add(c);
        }
        system.debug('caseList--'+caseList);
        if(caseList.size()>0){
            update caseList;
        }
        system.debug('caseList--'+caseList);
    }    
    global void finish(Database.BatchableContext bc){
        
    }   
}
Users are able to see the 'campaing member status' related list in campaign page. Wanted to restrict users under certain profile from editing/creating  'campaing member status' record.
I want to change the contact associated with the partner user to another contact, but the contact field is not displayed on the edit screen of the user. Is there no way to change it? Thank you.
  • July 15, 2020
  • Like
  • 0
I want to user the bulk api to get the contact information. Where can I find the column names in the contact table?
Hi everyone,

I'm trying to run a query with LIKE condition but I get a null response when I add the LIKE condition.
 
SELECT Property__r.Geolocation__Latitude__s,Property__r.Geolocation__Longitude__s,Property__r.Name,Id,ListingHeadline__c,Name,PriceDisplayedWebsite__c,PropertySuburb__c,PropertyType__c,Property_Zone__c,Property__c,Reference__c,TotalFloorArea__c FROM Opportunity WHERE IsClosed=false AND PublishedToWebsite__c=true AND Reference__c LIKE '%JG%' AND Property__c IN (SELECT Id FROM Property__c WHERE PublishedToWebsite__c=true)

If I remove the 
Reference__c LIKE '%JG%'

part, it works fine I get the results.
And I can confirm it does have data that match the LIKE condition.

Any idea on what's wrong with the above query?
Hi All,

For context and background, I am working with an organization that is using Financial Services Cloud. Within FSC, there is a custom object called "Financial Accounts" and within this object there is a record type called "Credit Card".

Within opportunities, we are creating a workflow where users are forced to link a valid credit card (financial account) record in order to close their credit card-related opportunities. I am looking to create a trigger (and test class for eventual deployment) on the financial account record so that a custom checkbox field called "Linked To Won Opportunity" (API: LinkedToWonOpp__c) is set to TRUE when it has been linked to an opportunity record where the Stage = Closed Won. Conversely, I want create the trigger so it also updates this field "Linked To Won Opportunity" to FALSE if the opportunity record in which it was linked is either changed back from Closed Won to any open status OR if the link between the financial account record and opportunity no longer exists (i.e. the user deleted the card record ID from the Financial Account (lookup) field placed on the opportunity).

Any help or direction is GREATLY appreciated.

Thanks,

Ricki
Hello,

I have created a component to search Account's opportunities by keyword. But when pressing the search button on my component, the results return all opportunities, even those not related to the Account.

I have tried to modified my SOQL request but can't find the right way request only the opportunities that belongs to a particular account.

Am I allowed to passed an Object as a paramter in my List?
Thank you?

here is my modified request:
public with sharing class SearchOpportunityController {
	
	@AuraEnabled
 	public static List <Opportunity> getOppty(String searchOppty, Account a) {
  		String accId = a.Id;
        String searchKey = searchOppty + '%';
 		List <Opportunity> oppties = new List <Opportunity>();
  		List <Opportunity> lstOfOppty = [SELECT Id, Name, StageName, Amount, CloseDate FROM Opportunity
                                   		 WHERE Name LIKE: searchKey AND AccountId = :accId];
 		System.debug('lstOfOppty' +lstOfOppty);
        
  		for (Opportunity opp: lstOfOppty) {
   			oppties.add(opp);
            System.debug('oppties' +oppties);
  		}
  		return oppties;
 	}
}

 
I have input Checkboxes in the VF page on the Lead record with the requirement that if one of the field is checked the other should be checked as well when the save button is clicked on the VF Page and it is the same when being unchecked
User-added imageThere is this 3rd field on the Lead record which dont exists on the VF Page but needs to updated depending on the above two fields
User-added imagebelow is what I tried
VF Page
<apex:pageblockSectionItem >
                        <apex:outputPanel >
                            <div class="ListLevel01">
                                <apex:outputLabel value="Type 1"></apex:outputLabel>
                            </div> 
                        </apex:outputPanel>
                        <apex:inputcheckbox value="{!leadRec.Type_I_AI__c}" styleClass="ListLevel01">
                            <apex:actionSupport event="onchange" reRender="form" status="status"/>
                        </apex:inputcheckbox>
                    </apex:pageblockSectionItem>
                    <apex:pageblockSectionItem >
                        <apex:outputPanel >
                            <div class="ListLevel01">
                                <apex:outputLabel value="Type 1"></apex:outputLabel>
                            </div> 
                        </apex:outputPanel>
                        <apex:inputcheckbox value="{!leadRec.Type_I_DOM__c}" styleClass="ListLevel01">
                            <apex:actionSupport event="onchange" reRender="form" status="status"/>
                        </apex:inputcheckbox>
                    </apex:pageblockSectionItem>

             ..................
  </apex:pageblock>    
  <apex:commandButton value="Save" style="margin-left:900px;" action="{!finalUpdates}" rerender="form"  oncomplete="RefreshPrimaryTab('{!Lead.id}'); return true;" />
 </apex:form>
The finalUpdates updates the Lead record which in turn fires the trigger like below
set<Id> leadIds = new set<Id>();
    for(Lead l : Trigger.new){
        leadIds.add(l.Id);
    }
    if(!leadIds.isempty() && checkRecursiveTrigger.ranOnce == false)
       LeadTriggerHandler.updateAOI(trigger.newMap, trigger.oldMap);
}
Apex Class
Public class LeadTriggerHandler{
 public static void updateAOI(Map<Id, Lead> newLeads, Map<Id, Lead> oldLeads){
    Set<Id> resultIds = (new Map<Id,Lead>(newLeads)).keySet();
           List<Lead> Leadlist = [Select Id, Type_I__c,Type_I_AI__c,Type_I_DOM__c
                               from Lead WHERE Id IN: resultIds];
        List<Lead> updateList = new List<Lead>();
        set<id> LeadIds= new set<Id>();
        for(Lead l : Leadlist){
                     if(   newLeads.get(l.Id).Type_I_DOM__c == true || newLeads.get(l.Id).Type_I_AI__c  == true)
            {
                l.Type_I_DOM__c = true;
                l.Type_I_AI__c  = true;
                l.Type_I__c = true;
                if(!leadIds.contains(l.Id)){
                    leadIds.add(l.Id);
                    updateList.add(l);
                }                
            }
            
            if(newLeads.get(l.Id).Type_I_DOM__c == false || newLeads.get(l.Id).Type_I_AI__c  == false)
            {
               l.Type_I_DOM__c = false;
                l.Type_I_AI__c  = false;
                l.Type_I__c = false;
                if(!leadIds.contains(l.Id)){
                    leadIds.add(l.Id);
                    updateList.add(l);
                }                
            }
         .............
But this doesnt work as expected, it executes both the if condition if condition if I just click on just one field and not even touch the other field in the end even if 1 field is selected I see false on all the three fields. I now understand my approach here is wrong but not sure how to handle it. Any help is greatly appreciated
  • July 13, 2020
  • Like
  • 0
Hi All,

I have custome object 'PriceReconfirmation__c' and it has notes and attachment related List and also This object having Account Lookup field.
I wanted to clone the attachment from  "PriceReconfirmation__c" attachment to Account lookup record Notes and attachment.

could anyone help me out here. 
Thanks !
public class class2 {

 public list<string> lststatename{get;set;}
       
       public list<string> lstrating{get;set;}
       
        public map<string, string>statemap{get;set;} 
        
        
          public list<string>selectedvalues{get;set;}

 public  class2(){
 
 
 
 
 
      string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
       

      map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 

    list<object>  values1= (list<object>)metadatamap.get('data');  
    
     lststatename= new list<string>();
    
    lstrating= new list<string>();
    
         statemap= new map<String, string>(); 
        
        
          for(object parsed : values1){
          
             map<string,object>  values = (map<string,object>)parsed;
          
          string statename = string.valueof(values.get('stateName'));
          
          
          string value = string.valueof(values.get('value'));
          
          
          lststatename.add(statename);
          
          
       
          
          
           statemap.put(statename, value);
}


 }
 
 
 
   public PageReference test(){
   
  
   
   //code to be written 
   
   
   
    return null;
   
   
   
   }
}
 
<apex:page controller="class2">
  
  
  <apex:form >
  
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!lststatename}" var="a">
      <li ><apex:inputCheckbox value="{!statemap[a]}" /><label>{!a}</label></li>
        </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm"/>
   
   
    <apex:outputLabel id="fm">
    
      the selected values are :
    </apex:outputLabel>
  </apex:form>
  
  
</apex:page>

User-added image

onclicking on the test button , the values are to be displayed, how to achieve this functionality ?

Thanks in advance
global Class CongaImpl{

     static String version = '/services/Soap/u/39.0/';
     static String partnerUrl = Url.getSalesforceBaseUrl().toExternalForm()+version+UserInfo.getOrganizationId().subString(0,15);  
     static String congaUrl;
     
     Webservice static string leaseAgreementDocument(String recordId) {
    //  string queid='[Borrower]Label.Borrower_details,[Amortization]Label.Amortization_details,[Equipment]Label.Equipment_Details&TemplateId=Label.Hyphecation_agreement';
    //   System.debug('>>##Lease_Agreement_letter#:'+getQerystring('Lease_Agreement_letter'));
       //[Borrowersdetails]a0p5D000000D7Ce Lease_Agreement_letter
     // congaUrl=Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&QueryId='+getQerystring('Lease_Agreement_letter')+'&DS7=1&OFN='+bName.deleteWhitespace()+'_LA&id='+recordId.subString(0,15);
        congaUrl = Label.Conga_URL+userinfo.getsessionId()+'&serverUrl='+partnerUrl+'&Id='+recordId+'&QueryId=[LA]a8G1k0000004KsR,[EQ]a8G1k0000004KsW&TemplateId=a8O1k0000008dpp&DefaultPDF=1' ;
        
        System.debug('congaUrl'+congaUrl);
        return getCalloutToConga(congaUrl);
     }
     
     public static String getCalloutToConga(String url) {
        system.debug('## URL ::'+url);
        // Instantiate a new http object
        Http h = new Http();

        // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        req.setTimeout(60000);
        // Send the request, and return a response
        try{
            HttpResponse res = h.send(req);
            if(res.getStatusCode() != 200){
                system.debug('## status <>200'+res);
                return res.getStatus();
            } else if(!Pattern.matches('[a-zA-Z0-9]{18}',res.getBody())){
                system.debug('## status ==200'+res);
                return res.getBody();
            }

        } catch(System.CalloutException em){
            System.debug('## Callout Error message: '+em.getMessage());
        } 
        return 'Document Created successfully!!';
    }

}
This is the class. I tried to check if any of the methods are being called in any of the test classes but no luck there either. Any help would be appreciated.
 
Hi Team,

can you help me linking the contact to the created account?

i have created a new APEX for creating an account. i need to create a contact and link the contact to the account.

Can you please help me with this.

i also tried creating the Seprate Contact object. but i need to know how to link Account to Contact.
Hello,

I have the following Visualforce page along wiht Apex Controller and Test Class. When I run the test class the coverage for Apex Controller is 0%, any idea on how to solve this issue:

Visualforce Page:

<apex:page standardController="Bid_Summaries__c" recordSetVar="Bid_Summaries__c" extensions="BidSummariesController"> <apex:pageBlock title="Bid Summary"> <apex:slds /> <style type="text/css"> body {background-color: white;} p { font-weight: bold; } p { font-style: italic;} h1 { color: #f00; } p { background-color: #eec; } newLink { color: #f60; font-weight: bold; } </style> <apex:page lightningStylesheets="true"/> <apex:form > <apex:pageBlockTable value="{! Bid_Summaries__c }" var="b"> <apex:column value="{! b.Name }"/> <apex:column value="{! b.Original_Budget__c }"/> <apex:column value="{! b.Upgrade_Amount__c }"/> <apex:column value="{! b.Budget_incl_Upgrades__c }"/> <apex:column value="{! b.TJH_Service_Fee__c }"/> <apex:column value="{! b.Concession__c }"/> <apex:column value="{! b.Upgrade_Total__c}"/> </apex:pageBlockTable> </apex:form> </apex:pageBlock> </apex:page>

Apex Controller:

​​​​​​public class BidSummariesController {

    public BidSummariesController(ApexPages.StandardController controller) {

    }

        public List<Bid_Summaries__c> Bid {get; set;}
        public BidSummariesController(){
        List<Bid_Summaries__c> Bid= [Select Id, Selected_Option__c,Concession__c, Status__c,TJH_Service_Fee__c,
                                    Upgrade_Amount__c,Upgrade_Total__c, Original_Budget__c From Bid_Summaries__c] ;
    }
                       PageReference pageRef = Page.BidSummary1;                    
                       public list <Bid_Summaries__c> getBid(){
                                              
                       return Bid;
                       
        }
    
    }


Test Class:

@isTest 

    public class BidSummariesControllertest {
        
        private static testMethod void BidSummariesController() {
            
         test.StartTest();
            
         Bid_Summaries__c b = new Bid_Summaries__c();
         
         b.Upgrade_Amount__c     = 1000;
         b.Concession__c         = 1000;         
         b.Original_Budget__c = 100;
         b.Status__c  = 'New';
            
            Insert b;
            
         
          
           test.stopTest(); 
        PageReference pageRef = Page.BidSummary1;
        Test.setCurrentPage(pageRef);
        ApexPages.StandardController sc = new ApexPages.StandardController(b);
        
      
             
           
             
            List<Bid_Summaries__c> Bids = [Select Id, Selected_Option__c,Concession__c, Status__c,TJH_Service_Fee__c,
                                    Upgrade_Amount__c,Upgrade_Total__c, Original_Budget__c From Bid_Summaries__c ];
                    
                    Update Bids;
            
            
            
        } 
        
        List<Bid_Summaries__c> Bids = New List<Bid_Summaries__c>();
             
               
                                    
          
        }