• pcon
  • ALL STAR
  • 14913 Points
  • Member since 2011
  • Principal Software Engineer
  • Red Hat


Badges

  • Chatter
    Feed
  • 445
    Best Answers
  • 0
    Likes Received
  • 10
    Likes Given
  • 1
    Questions
  • 3195
    Replies
ublic class MyUploadStatementController {
    public String LeadsId {get;set;}
    public List<Attachment> docs{get;set;}
    public List<Attachment> insertedDocs{get;set;}
    public string attNames{get;set;}
    
    public MyUploadStatementController(){
        LeadsId = ApexPages.currentPage().getParameters().get('Id');
        system.debug('LeadId -->'+LeadsId);
        attNames = '';
        docs = new List<Attachment>();
        insertedDocs = new List<Attachment>();
    }
    
    public pagereference prepareSFDocuments(){           
        try{     
            //system.debug('**'+leadobj);
            attNames = attNames.removeEnd('\n');
            List<string> atts = attNames.split('\n');        
            
            //sfDocs = new List<SFDocument>();       
            for(String attName:atts){
                List<string> nameSplit = attName.split('\t');
                system.debug('Attname just '+attName);
                Attachment doc = new Attachment(Name=nameSplit[0], ParentId=LeadsId );
                docs.add(doc);
                system.debug('Debug Docs '+docs);
                //SFDocument d = new SFDocument(nameSplit[0], leadobj.id,Long.valueOf(nameSplit[1]),getDisplaySize(Long.valueOf(nameSplit[1])));
                //sfDocs.add(d);
            }
            
            System.debug('Attachment List-->'+docs);
            //Integer.valueOf('***'+docs.size());
        }catch(Exception ex){ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage()+'\n'+ex.getStackTraceString());
                             ApexPages.addMessage(myMsg);}
        return null;
    }
    
    public pagereference updateDocs(){
        //Integer.valueof('pare'+parentId);
        try{
            system.debug('Dropbox docs '+docs);
            for(Attachment da : docs){
                system.debug('Inside For Loop DropBox '+da);
                da.ParentId = LeadsId;
            }
            if(docs.size()>0)
                insert docs;
            insertedDocs.addAll(docs);
            docs = new List<Attachment>();
        }catch(Exception ex){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
                             ApexPages.addMessage(myMsg);
        }
        return null;
    }
    
    @RemoteAction
    public static void UploadAttachment(String LeadId){
        
    }
}
I'm integrating Salesforce to other application(Ruby). I'm able to sync data both ways. But while updating data from Application to salesforce, every time i have to provide access token. So is there any way to get a permanent Access token?
Thank You..
Hi.

I'm new in Salesforce.

I create a sandbox and i tried to move my change (some new fields and put that foelds in account page). I create the chage set, y validate it, i implement it and all it's ok.

I review the Account object and my changes are applied. I review the account page and my change are applied. BUT i enter in the application and I don't see my changes!!! What is that I'm doing wrong?

PD - I move from one sandbox to another sandbox

Thanks in advance

All i need to get response  from sap application through the rest callouts . When i tried to use the Chrome APP 'Advanced Rest Client' and  postman have passed the appropriate URL and Content  with  GET AND POST method I was able to retrieve the values from local server database.
For EG : If i pass request  92126 then i was able to get response  'SAN DIEGO' which is correct.

Here is the link (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US)for Advanced REST Client.

1)i had created a remotesite setting 
2) When i created this REST class in SAlesforce and tried invoking the End Point then its throwing this error.

System.HttpResponse[Status=Service Unavailable, StatusCode=503]
# as the web api url  which is provided to us is in local sql  server i.e  hosted in private,  as we know  THAT salesforce for making callouts the urls must be EXPOSED  in public... bt the url is in private only for the security reasons not hosted in public..we should achieve iT COMPULSARY THERE WILL A ANY SOLUTION FOR ALL THE QUESTIONS   .. IS any way is there to acheive it ??  ..what changeS  should be done in salesforce or LOCAL server to communicate to eachother ..and allows to make the callout ???
What this error?

KeyManagerFactory not initialized
Error is in expression '{!accessToken}' in component <apex:page> in page document407_access_token: Class.checkingAccessToken.accessToken: line 50, column 1
An unexpected error has occurred. Your development organization has been notified.


What I did so far?
1. Created a vf page and controller
2. Controller contains http callouts.
3. Custom link to call this VF page.
4. When I click the link. its showing the above error
How to parse the response 
 <?xml version=\"1.0\" encoding=\"UTF-8\"?><methodResponse xmlns:ex="http://ws.apache.org/xmlrpc/namespaces/extensions"><params><param><value><array><data><value><boolean>1</boolean></value><value>OK</value></data></array></value></param></params></methodResponse>

I wanted to write logic based on Boolean value in response but am unable to parse this one 
 
I'm in the "Salesforce Connect" module and trying to complete the set up to integrate a sample as requested:

"As part of this module, you integrate sample order data with the existing account data in your Salesforce Developer Edition. To go through the steps, you need to install a test package that configures the necessary schema on the account object, creates a Customer ID field, and assigns a value for Customer ID to each account.

Follow these steps to install the package.
Open a browser, and click here to start the installation.
Select Install for Admins Only.
Click Install."

When I click on the "click here" it takes me to a SFDC log in page, where I try to select my Dev Org login in username and password (from my production enviro).  It does not work and even after trying to reset my password I never receive an email and cannot log in.

Please help! 
Thanks,
Rochelle
Our group is changing over some code in response to a change in instance.  This code follows the methods outlined in the quick start guide. https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart.htm  At the moment, we acquire an auth token by hitting the login instance, and then query our numbered instance for data.

To prevent having to keep changing the configuration parameter to point to our new ID when it changes, is it possible to still query the login instance to get data back?  I've tested on my end without any luck, but I figured I'd check to see if I'm missing anything.

We're exploring setting up a custom domain, which will likely  be our alternative, but the easier solution would be better.

 
Hello - I created a pre-chat survey for my new verions of Live Agent, but in testing, clicking the link to chat now forces a login. How do I serve up the questions without logging in? Without the pre-chat quesitons, Live Agent launches just fine without a need to login and launching the visualforce page works. Any suggestions would be much appreciated! Thank you in advance!
 
I am attempting to parse MatterMark's API, but I am planning to do so selectively, picking only the value pairs that are relevant. The example JSON response is available to be viewed in MatterMark's documentation (here).

Here's my Wrapper:
 
public class MMarkWrapper {
    public class mmark_company_profile {
        public string name {get;set;}
        public string description {get;set;}
        public string employees {get;set;}
        public string employees_6_months_ago {get;set;}
        public string last_funding_amount {get;set;}
        public string last_funding_date {get;set;}
        public string country {get;set;}
        public string total_funding {get;set;}
        public string acquired_by {get;set;}
        public List<mmark_funding_round> mmark_funding_rounds {get;set;}
        
    }
    public class mmark_funding_round {
        public string amount {get;set;}
        public string transaction_currency {get;set;}
        public string series {get;set;}
        public string funding_date {get;set;}
        public string investors {get;set;}
        
    }
    
    public List<mmark_company_profile> mmark_company_profile_list {get; set;}

}

And the Parser:
 
public class MMarkParser {
    public MMarkWrapper wrapper {
        get;
        set;
    }
    
    public void parse() {
        
        //request class
        HTTPRequest request = new HTTPRequest();
        request.setEndpoint(Label.MatterMarkAPI+'/domains/'+ 'marketinvoice.com' +'/companies?key=' +'c878f447941828d91d53ffbebae068cdb7624fb257cca98e2672e8148e039c1c');  
        request.setMethod('GET');
        
        //response class
        HTTP h = new HTTP();
        HTTPResponse response = h.send(request); 
        
        
        wrapper = (MMarkWrapper) JSON.deserialize(response.getBody(), MMarkWrapper.class);
        System.debug(wrapper);
        
    }
    
}

I am trying to get it displayed on this page, but all I am getting is a blank page...
 
<apex:page controller="MMarkParser">
    <apex:form >
        <apex:pageBlock title="MMarkParserResponse">
            <apex:pageBlockButtons >
                <apex:commandButton value="submit" action="{!parse}" reRender="mmark_company_profile"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection id="mmark_company_profile" columns="1">
                <apex:repeat value="{!wrapper.mmark_company_profile_list}" var="mmark_company_profile">
                    <apex:pageBlockSection columns="2">
                        <apex:facet name="header">Company {!mmark_company_profile.name}</apex:facet>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Description" for="description" />
                            <apex:outputText value="{!mmark_company_profile.description}" id="description" />
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Employees" for="employees" />
                            <apex:outputText value="{!mmark_company_profile.employees}" id="employees" />
                        </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection columns="1">
                        <apex:facet name="header">Funding {!mmark_company_profile.name} Series</apex:facet>
                        <apex:pageBlockTable value="{!mmark_company_profile.mmark_funding_rounds}" var="item" id="mmark_funding_rounds">
                            <apex:column value="{!item.amount}" headerValue="Amount" />
                            <apex:column value="{!item.transaction_currency}" headerValue="Transaction Currency" />
                            <apex:column value="{!item.series}" headerValue="Series" />
                            <apex:column value="{!item.funding_date}" headerValue="Funding Date" />
                        </apex:pageBlockTable>
                    </apex:pageBlockSection>
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock> 
    </apex:form>
</apex:page>

I've been trying to debug it with no success, any ideas why this may be not working?
Hello,

I'm new to Apex and SOQl. I have two objects; Accounts (Master object) and Appointments (Child object) and I'm trying to write a trigger (With SOQL query) that returns the most recent appointment date (Max date) per account on a custom field (Most_Recent_Appointment_Date__c) that is built on the account (Persons account) object:
 
Object #1: (Appointments)
 
Appointment ID  Account ID,   Name,  Apt Date,   Weight....etc.
---------------------------------------------------------------------------------
Apts_001112       001                John      01/01/2017     160
Apts_001114       002                Nicole   11/05/2016      180
Apts_001113       001                John      04/05/2017     175
Apts_001115       003                Mark     05/05/2017      190   
Apts_001116       002                Nicole   12/15/2016      200
 
Object #2: (Accounts)
 
 ID,      Name....etc.
--------------------------
 001     John    
 002     Nicole   
 001     John     
 003     Mark      
 002     Nicole
-----------------------------------------------------------------------------------------------------------------------------------------------------
 
Trigger MostRecentAppointmentDate on Accounts (After update, after insert) {

List <Accounts> AccountsList = new List<Accounts>();

Set<id> AcntsID = new Set<id>();
    for(Account a:trigger.new) {
 AcntsID.add(a.ID);
}

For (Appointments Apts : Trigger.new) {
Appointments MostRecentApts = [SELECT Scheduled_date__c, Weight__c, Patient__c
                                            FROM Appointments__c
                                            WHERE Patients__c IN:AcntsID
                                            GROUP BY Patients__c
                                            ORDER BY Scheduled_date__c DESC
                                            LIMIT 1];

Set Most_Recent_Appointment_Date__c = MostRecentApts

}
Hi all

what is the apex code for sms magic

Is it possible to set the parent id on an asset other than using the constructor method?  I need to set the parent id for an asset in a trigger method.  This code does not work:

a.parentId = parentAsset.id;

Results in:  Save error: Invalid field parentId for SObject Asset

My user does have access to the object and the parent field.  I can set the parent id using the constructor method:

Asset a = new Asset(name='test component with parent',
                    hin__c = 'CRC10890L516',
                    recordtype =bc,
                    dealer_key__c = '43536.001',
                    dealer_brand_key__c = '43536.001CL',
                    parentId = '02i54000000hS4aAAE') 

Unfortunately that will not work for my use case.

Ideas?
 

Hi, 

How can I align the following to the left of the page, its a pdf. Screenshot of the issue
I want to shift all the text to the left with this formet, here is the section of code for this- 
<tr>
                <td colspan="4"> </td>
            </tr>
            <tr>
                <td colspan="4" style="font-weight: bold; border-bottom-style: solid; border-bottom-width: thick;
                    border-bottom-color: #30b55a;">
                    Campaign Information </td>
            </tr>
              
                    <tr>
                            <td style="color: #808080; border-right-style: solid; border-right-width: thin;
                                border-right-color: #30b55a;">
                                Campaign Name </td>
                            <td align="left">
                                {!Opportunity.Name} </td>
                        </tr>
                    <tr>                    
                            <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                                border-right-color: #30b55a;">
                                Brand </td>
                            <td style="text-align:left">
                                {!Opportunity.Account.Name} </td>
                        </tr>
                       
            <tr>
                <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                    border-right-color: #30b55a;">
                    Start Date
                </td>
                    <td style="font-weight: normal">
                        <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
                        <apex:param value="{!Opportunity.Campaign_Start_Date__c}" /> 
                        </apex:outputText>
                    </td>
            </tr>
            
            <tr>
                <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                    border-right-color: #30b55a;">
                    End Date
                </td>
                    <td style="font-weight: normal">
                        <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
                            <apex:param value="{!Opportunity.Campaign_End_Date__c}" /> 
                        </apex:outputText>
                    </td>
            </tr>
            
             <tr>
                <td align="right" style="color: #808080; border-right-style: solid; border-right-width: thin;
                    border-right-color: #30b55a;">
                    Duration 
                </td>
                    <td style="font-weight: normal">
                        <apex:outputText value="{0,number,0}">
                            <apex:param value="{!Opportunity.Campaign_Duration__c}"/>
                        </apex:outputText> 
                    </td>
            </tr>

Please help out. Thank you !
I'm receiving a JSON string from another system in the format below. These records already exist in Salesforce. I want to only query these records in salesforce, set a boolean field to false in all of them and update.
{ "bacctList" : 
     [{
       "RC_Account_No__c" : "RC-2",
       "A_c_Number__c" : "111",
       "Bank_code__c" : "250655"
      },
      {
       "RC_Account_No__c" : "RC-1",
       "A_c_Number__c" : "222",
       "Bank_code__c" : "198765"
      }]
   }

The below code works fine, the issue is it's not bulkified.
@RestResource(urlMapping='/dosystem/bankaccounts/*')
global with sharing class BankAccountWebservice{
   
 @HttpPatch
    global static BankAccountWrapper doPatch(List<Bank_Account__c> bacctList) {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        BankAccountWrapper response = new BankAccountWrapper();
        
        List<Bank_Account__c> bankAccountsToUpdate= new List<Bank_Account__c>();

        for(integer i=0; i<bacctList.size(); i++){
            List<Bank_Account__c> ac = [SELECT Debit_Order_A_c__c,A_c_Number__c,Bank_code__c,RC_Account_No__c  
            FROM Bank_Account__c 
            WHERE (RC_Account_No__c =: bacctList[i].RC_Account_No__c AND  A_c_Number__c =: bacctList[i].A_c_Number__c AND Bank_code__c =: bacctList[i].Bank_code__c)];
            
            for(integer j=0; j< ac.size(); j++){
                ac[j].Debit_Order_A_c__c = false;       
                bankAccountsToUpdate.add(ac[j]);
             }    
        }
        
        try {
            update bankAccountsToUpdate;

            response.bacctList = bankAccountsToUpdate;
            response.status = 'Success';
            response.message = bacctList.size()+' Records Updated successfully';
        }
        catch(Exception exc) {
            res.StatusCode = 500;
            response.bacctList = null;
            response.status = 'Error';
            response.message = 'Your request failed with the following error: ' + exc.getMessage();
        }
        
        return response;
    }
    
    global class BankAccountWrapper {
        public List<Bank_Account__c> bacctList;
        public String status;
        public String message;
        
        public BankAccountWrapper(){
            bacctList = new List<Bank_Account__c>();
        }
    }   
}

The problem is the FOR loop. I tried using the IN clause in SOQL but the problem is im not getting the ID in the JSON string.
List<Bank_Account__c> bankAccountsToUpdate= new List<Bank_Account__c>();
        integer updatedRecordCount=0;
        
        List<Bank_Account__c> ac= [select Name,Debit_Order_A_c__c,A_c_Number__c,Bank_code__c From Bank_Account__c where Id IN : bacctList];
                    
		for(integer i=0; i<ac.size(); i++){                                    
			ac[i].Debit_Order_A_c__c = false;       
			bankAccountsToUpdate.add(ac[i]);
			updatedRecordCount++;                 
		
		}

PLEASE HELP.

 
Hi folks,

I've been powering my way through Trailhead recently, I've now gone through all of the Admin (just looking through the Advanced trail currently) and also want to gain a better understanding of Programmatic side/more Development focused features.

It probably helps if I state that I've worked in Sales for most of my career so  stepping into the technical realm is a fairly big jump for me! Can anyone advise:

- Would it be best to cotinue with the advanced admin trail *before* moving onto the 'Developer - Beginner' trail, or is it worth learning the programmatic side along with declarative before tackling the final trail?

- Is there a good place to start learning APEX? I have a very basic understanding of the code from what i've managed to gleam through Trailhead, but it seems like a 'JAVA/C# for Dummies' book or something similar may be a good idea?

If anyone could spare 2 mins to give me some advice I'd really appreciate it!

Thanks in advance

Jack
Hi guys,

I'm trying to setup email to case on an org but I keep running into this issue, it's driving me insane as I had this set up already using the exact same email address and it worked fine. Can anyone help me figure out what the below error message means? I have no idea what picklist is causing this to happen all of a sudden. 

INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST : bad value for restricted picklist field: No
Hello all,

I have completed creating trigger and helper class, if i close the maintanance request, new maintanence request is gettting created as expected with same vehicle, report date and due date.  But i am getting this errors.

Challenge Not yet complete... here's what's wrong: 
Inserting a new Maintenance Request of type 'Repair' and then closing it did not work as expected. The challenge was NOT expecting to find a Maintenance Request with the same Vehicle and the Status of 'New' and of Type 'Routine Maintenance'. However, it did.

What is the issue.

Thanks.

Last night, we started having tests fail in our dev environment.  We have the following methods (shortened)

 



public static void updateTargetDate(...) {
     Set<Id> futureIds = new Set<Id>();
     ...
     // Add Ids
     ...
     if (!futureIds.isEmpty()) {
          updateTargetDateFromMilestone(futureIds);
     }
}

@future
public static void updateTargetDateFromMilestone(Set<Id> caseIds) {
     ...
}

 

Yesterday at noon (we run all tests in dev at noon and midnight) all the tests were running without error.  At midnight most of our tests were failing with the following error:

 

System.TypeException: Invalid conversion from runtime type SET<String> to SET<Id>

 

with a referral to the method of updateTargetDateFromMilestone(Set<Id> caseIds).  This file has not been updated since June 24th 2011.

 

So the question is, has anyone else seen this error crop up?  I know that in Apex Strings and Id "should" be interchangeable, however, it doesn't matter in this case since the Set being made is of type Id and the Set parameter for the calling method is of type Id.

  • September 30, 2011
  • Like
  • 0
Hello All,
I am learning on Asynchronous Apex Trigger, recently introduced on summer release '19. I have created a custom object Event_testing and added it to Change Data capture and created a new trigger, that has a debug statement to capture the trigger.new values. However, The custom event trigger is not even called after the insert operation. 
Any advise would be much appreciated. 
trigger Testing_tgr1 on Event_testing__ChangeEvent (after insert) {
    for(Event_testing__ChangeEvent c : trigger.new){
        system.debug('C is '+c);
        
    }
}

Thank you.
Regards, 
Sujendran. 
​​​​​​​
ublic class MyUploadStatementController {
    public String LeadsId {get;set;}
    public List<Attachment> docs{get;set;}
    public List<Attachment> insertedDocs{get;set;}
    public string attNames{get;set;}
    
    public MyUploadStatementController(){
        LeadsId = ApexPages.currentPage().getParameters().get('Id');
        system.debug('LeadId -->'+LeadsId);
        attNames = '';
        docs = new List<Attachment>();
        insertedDocs = new List<Attachment>();
    }
    
    public pagereference prepareSFDocuments(){           
        try{     
            //system.debug('**'+leadobj);
            attNames = attNames.removeEnd('\n');
            List<string> atts = attNames.split('\n');        
            
            //sfDocs = new List<SFDocument>();       
            for(String attName:atts){
                List<string> nameSplit = attName.split('\t');
                system.debug('Attname just '+attName);
                Attachment doc = new Attachment(Name=nameSplit[0], ParentId=LeadsId );
                docs.add(doc);
                system.debug('Debug Docs '+docs);
                //SFDocument d = new SFDocument(nameSplit[0], leadobj.id,Long.valueOf(nameSplit[1]),getDisplaySize(Long.valueOf(nameSplit[1])));
                //sfDocs.add(d);
            }
            
            System.debug('Attachment List-->'+docs);
            //Integer.valueOf('***'+docs.size());
        }catch(Exception ex){ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage()+'\n'+ex.getStackTraceString());
                             ApexPages.addMessage(myMsg);}
        return null;
    }
    
    public pagereference updateDocs(){
        //Integer.valueof('pare'+parentId);
        try{
            system.debug('Dropbox docs '+docs);
            for(Attachment da : docs){
                system.debug('Inside For Loop DropBox '+da);
                da.ParentId = LeadsId;
            }
            if(docs.size()>0)
                insert docs;
            insertedDocs.addAll(docs);
            docs = new List<Attachment>();
        }catch(Exception ex){
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
                             ApexPages.addMessage(myMsg);
        }
        return null;
    }
    
    @RemoteAction
    public static void UploadAttachment(String LeadId){
        
    }
}
1. Create a SSO app with enable SAML .
2. When I configure a url "http://example.com/SAML/ACS" for ACS URL, actually it will be changed to "https://example.com/SAML/ACS" when I sign in my own application by salesforce.
3. But the locahost is rigid. The "http://localhost/SAML/ACS" won't be changed.
I want to know whether it is a policy. BTW, there is no document for it.
HI,
I need help to cover following code into my test class
User-added imageUser-added imageUser-added image
Hi guys,
 I have a doubt on ant deployment tool, iam new to this...
So what my doubt is... I have a two orgs x and y ,, I was retrieving Apex classes from x org and deploying to y org and next I have done some modifications on  Apex class  in x org and retrieve again and deployed to y org but I was getting an error because the Apex classes with same name are already existed in y org as we deployed at first time ,, so can any one tell me is it possible to override those classes ,,if it is please explain
thanks.
Hi guys,

I know 'with sharing' enforces sharing rules of the current user and 'Without sharing' doesn't.
My doubt is, what is sharing rules? is it the criteria/owner based sharing rule we write for an object? or does it mean the access a user has on an object?

Where do we use these keywords in real time?
Is the current user, the user who executes the code?
I'm integrating Salesforce to other application(Ruby). I'm able to sync data both ways. But while updating data from Application to salesforce, every time i have to provide access token. So is there any way to get a permanent Access token?
Thank You..
A apex class is referred by multiple Lightning components.  is that good practice ? Bad Practice ? Please also answer WHY ? 
public class Bucket1controller {

public Bucket1__c buck1 = new Bucket1__c();

public Bucket1__c getbuck1(){


return buck1;
}

    public Bucket1controller(ApexPages.StandardController controller) {

    }

public pageReference Bucket1form2(){


return Page.Bucket1form2page;
}

public PageReference Saveall(){
Bucket1__c b = new Bucket1__c();
b.Aadhar_Number__c =buck1.Aadhar_Number__c;
b.CBIL__c =buck1.CBIL__c;

b.PAN_Number__c=buck1.PAN_Number__c;
b.Start_Date_and_TimeStamp__c = buck1.Start_Date_and_TimeStamp__c;
b.Accomodation_Type__c= buck1.Accomodation_Type__c;
b.Already_have_a_Loan__c =buck1.Already_have_a_Loan__c;
b.Borrower_Name__c=buck1.Borrower_Name__c;
b.Company_Name__c = buck1.Company_Name__c;
b.Company_Type__c = buck1.Company_Type__c;
b.Credit_card_holder__c = buck1.Credit_card_holder__c;
b.Date_of_birth__c  = buck1.Date_of_birth__c;

b.Eligibility_Check__c = buck1.Eligibility_Check__c;
b.Email__c=buck1.Email__c;
b.Full_Residential_Address__c = buck1.Full_Residential_Address__c;

b.Hoapital_clinic__c = buck1.Hoapital_clinic__c;

b.Last_Month_Salary__c = buck1.Last_Month_Salary__c;

b.Loan_Amount_Eligible__c = buck1.Loan_Amount_Eligible__c;
b.Loan_Amount__c = buck1.Loan_Amount__c;

b.Obligation_Amount__c = buck1.Obligation_Amount__c;
b.Phone_number__c = buck1.Phone_number__c;
b.Scheme__c =buck1.Scheme__c;
b.Treatment__c =buck1.Treatment__c;

insert b;

return Page.savedsuccessfully;
}
}
  • May 28, 2019
  • Like
  • 0
HI All,

I want to implement the group by logic using apex code. I will pass the list<sobject> records based on the single field I need to manipulate the group by logic. Please let me know if anyone has any suggestions.

Thanks,
Vijay
 
hello,

please help me how to
cover below code

 public void AccountSummaryExcdisable()
    {
        ReportTypes = 'PDF';
        Divisionlists = 'All';
        Countrylists = 'All';
        Timeslot = Timeslot;
        
        Schdate=Reportlibrary.ReportlibDateField__c;
        Schdate= System.Today();
        Reportlibrary.ReportlibDateField__c=Schdate;
        
        if(AWDNo != null || AWDNo !='')
        {
            DiscountNumber=AWDNo;
            Brands = 'Avis';
        }
        else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
        {
            DiscountNumber=BCDNo;
            Brands = 'Budget';
        }
        else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
        {
            DiscountNumber=PDNNo;
            Brands = 'Payless';         
        }           
        
        DiscountType = AcctDiscounttype;
        IataNumber = null;
        DateRangeFilter = 'Last 30 Days';
        
        /////////////////////////////////Check if an Account is globally mapped or not ///////////////////////////////
        
        if(Brands =='Avis')
        {
            ValidateBrand ='A' ;
            Disctno=AWDNo;
        }
        else if(Brands =='Budget')
        {
            ValidateBrand = 'B';
            Disctno=BCDNo;
        }
        else if(Brands =='Payless')
        {
            ValidateBrand = 'P';
            Disctno=PDNNo;    
        }
        
        System.debug('--Check brand--'+Brands);
        
        System.debug('Check the discount no---- on brand change---'+PDNNo);
        
        System.debug('--Check buildup--'+Disctno);
        
        
        if(Usrs == 'Corporate Account'||Usrs == 'Small Business Account' ||Usrs=='Partnership Account' || Userprof == 'Customer Community Plus Login User' || Userprof == 'Avis_Customer Community Plus'|| Usrs=='Corporate Account')
        {
            ABG_AccountGloballyMapped Globalmap=new ABG_AccountGloballyMapped();
            Globallymapped=Globalmap.Globallymapped;
            Globallymappedno=Globalmap.Globallymappedno;
            System.debug('Check the Globallymapped after ::'+Globallymapped);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        
        System.debug('onchaneg Discount number---'+DiscountNumber);
        CustomSdate = SchedCussdate.Custom_Start_Date__c;
        CustomSdate=System.Today().AddDays(-92);
        SchedCussdate.Custom_Start_Date__c=CustomSdate;
        CustomEdate = SchedCusEdate.Custom_End_Date__c;
        CustomEdate = System.Today();
        SchedCusEdate.Custom_End_Date__c = CustomEdate;
        
        
        
        if(ReportTile =='Account Summary Snapshot')
        {    
            DisableFlds = false;
            
            Disabledaterange = false;
            Disabledates=true;
            IataDisable = false;
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today().addYears(-1);
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today();
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
            
        }
        else if(ReportTile == 'Pending Reservation Report')
        {
            DateRangeFilter = 'Forward 30 Days';
            Disabledates=true;
            IataDisable = false;
            DisableFlds = false; 
            Disabledaterange = false;
            
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today();
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today().AddDays(92);
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
        }
        else if(ReportTile == 'On Rent Reservation Detail')
        {
            Disabledates=false;  
            IataDisable = false;   
            DisableFlds = false;  
            DateRangeFilter = '';
            
            Disabledaterange = false;             
            
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }           
        }
        else if( ReportTile =='Business Rewards Summary' || ReportTile == 'Enrollment Report')
        {
            Disabledates=true; 
            IataDisable = true;
            DisableFlds = false;
            
            Disabledaterange = false;
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
            
        }
        else if(ReportTile == 'Email Domain Report')
        {
            DateRangeFilter = 'Last 30 Days';
            IataDisable = true;
            DisableFlds = true;
            
            Disabledaterange = true;
            DisableDiscountno = true;
            if(EmailDomain == null || EmailDomain =='')
            {
                DisableSchdReportbutton = true;
            }
            else
            {
                DisableSchdReportbutton = false;
            }
        }
        else if(Usrs =='STC'&& ReportTile == 'Rebate Report')
        {
            DiscountType ='Buildup';
            IataDisable = true;
            DisableFlds = true;
            Disabledaterange = false;
            DisableDiscountno = false;
        }
        else
        {
            DisableFlds = false;
            
            Disabledaterange = false;
            IataDisable = false;
            Disabledates=true;
            System.debug('Heloouser---'+DiscountNumber);
            if(DiscountNumber== null || DiscountNumber =='')
            {
                DisableDiscountno = false; 
            }
            else
            {
                DisableDiscountno = true; 
            }
        }
        
        if(ReportTile=='Email Domain Report'||ReportTile=='Toll Report'|| ReportTile=='Rebate Report')
        {
            ReportTypes = 'Excel';
        }
        else
        {
            ReportTypes = 'PDF';
        }
        
        if(Usrs == 'Corporate Account'||Usrs == 'Small Business Account' || Usrs=='Partnership Account')
        {
            if(DiscountType == 'All Data')
            {
                if(AWDNo != null && AWDNo !='')
                {
                    DiscountNumber=AWDNo;
                    Brands = 'Avis';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
                {
                    DiscountNumber=BCDNo;
                    Brands = 'Budget';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
                {
                    DiscountNumber=PDNNo;
                    Brands = 'Payless';         
                }           
                
            }
            else if(DiscountType == 'Stem' || DiscountType == 'Divisional')
            {
                DiscountNumber=null;
                DisableDiscountno = false;
                if(AcctDiscounttype =='Divisional' && DiscountType =='Divisional')
                {
                    DiscountNumber=AWDNo;
                    System.debug('Check the  AcctDiscounttype :: Divisional ---'+AcctDiscounttype);
                    DisableDiscountno =true;
                }
                else if(AcctDiscounttype =='Stem' &&  DiscountType == 'Stem')
                {
                    System.debug('Check the  AcctDiscounttype :: Stem ---'+AcctDiscounttype);
                    DiscountNumber=AWDNo;
                    DisableDiscountno =true;
                }
                
            }
            else if(DiscountType =='Buildup')
            {
                System.debug('Check the AWDNo no -----'+AWDNo);
                if(AWDNo != null && AWDNo !='')
                {
                    System.debug('----------- AWDNo ----------');
                    DiscountNumber=AWDNo;
                    Brands = 'Avis';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo !=null))
                {
                    System.debug('----------- BCDNo ----------');
                    DiscountNumber=BCDNo;
                    Brands = 'Budget';
                }
                else if((AWDNo == null || AWDNo =='') && (BCDNo == null || BCDNo =='') && (PDNNo !=null))
                {
                    System.debug('----------- PDN ----------');
                    DiscountNumber=PDNNo;
                    Brands = 'Payless';         
                }   
                //Account is globally mapped build will be unfreezed
                if(Globallymapped == true)
                {
                    DisableDiscountno=false;
                }
                else if(Globallymapped ==false)
                {
                    DisableDiscountno=true;
                }   
            }
            else
            {
                DisableDiscountno=true;
            }
        }
        else if(Usrs == 'Admin'||Usrs == 'HQ')
        {
            DiscountNumber=null;
            if(ReportTile == 'Email Domain Report')
            {
                DisableDiscountno = true;
            }
            else
            {
                DisableDiscountno = false;
            }
            if(ReportTile == 'Rebate Report')
            {
                DiscountType ='Buildup';
                IataDisable = true;
                DisableFlds = true;
                Disabledaterange = false;
                DisableDiscountno = false;
            }
            
        }
        else if(Usrs =='STC')
        {
            if(ReportTile == 'Rebate Report'){
                
                DiscountType = 'Buildup';
            }
            else{
                
                DiscountType = 'All Data';
            }
            if(ReportTile == 'Email Domain Report')
            {
                DisableDiscountno = true;
                
            }
            else
            {
                if(DiscountType == 'Stem' || DiscountType == 'Divisional'|| DiscountType =='Buildup')
                {
                    DiscountNumber=null;
                    DisableDiscountno = false;
                }
                else
                {
                    DiscountNumber = UserDiscountno;
                    DisableDiscountno = true;
                }
            }
            
        }
        
        checkbox = false;
        DisableFrequency = false;
        DisableDays = false;
        disableInput = false;
        CustomdisableInput = false;
        TimeSlotDisable = false;
        DisableName = false;
        
        if(schtype == true)
        {
            DisableFrequency = true;
            DisableDays = true;
        }
        else if(Recurrence == true)
        {
            DisableFrequency = false;
            DisableDays = true;
        }
        
        if(ReportTile =='Account Summary Snapshot')
        {
            
            CustomSdate = SchedCussdate.Custom_Start_Date__c;
            CustomSdate=System.Today().addYears(-1);
            SchedCussdate.Custom_Start_Date__c=CustomSdate;
            CustomEdate = SchedCusEdate.Custom_End_Date__c;
            CustomEdate = System.Today();
            SchedCusEdate.Custom_End_Date__c = CustomEdate;
            
        }
        
        ButtonDisableAndEnable();    
    }

 
List<String> mergeFields = new List<String>{'Contact.AccountId','Contact.Name','Application__c.Name','Application__c.Contact__c'};
List<string> objectNames = new List<string>{'Contact','Application__c'};

I have a two list of strings. I want to use a Map variable to assign key value pairs. for objectNames key is Contact, values should contain Contact.AccountId','Contact.Name and for objectNames key is Application__c, values should contain Application__c.Name','Application__c.Contact__c
In reality , the mergefields and objectnames could be anything related to eachother not only Contact and Application__c

Map <string,List<String>> objectMap = new Map <string,List<String>>();

Please help on assigning a key value pair
Hello,

I am trying to solve the challange of the HTTP and Basic Callout module of Salesforce trailhead and I am having some queries in which you could point to the right direction:

1- The challange asked us to call this URL https://th-apex-http-callout.herokuapp.com/animals/:id in method getAnimalNameById... should that URL be in this form instead of the above https://th-apex-http-callout.herokuapp.com/animals?id ? Where id is a parameter in the URL.

2- When I tried to check the solution of the challange, Salesforce generated that error for me
"Challenge Not yet complete... here's what's wrong: 
Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById', is public and static, accepts an Integer and returns a String."
despite that my class implementation has this method declared as public static String as below in the code snippet:
 
public class AnimalLocator {
	
	public static String getAnimalNameById(Integer id) {
		
		Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals?id');
		request.setMethod('GET');
		
		HttpResponse response = http.send(request);
		List<Object> animals = NULL;
		String returnValue = NULL;
		
		// if the request was successful, then parse the JSON response
		if (response.getStatusCode() == 200) {
			Map<String, Object> result = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
			animals = (List<Object>) result.get('animals');
			System.debug(animals);
		}
		
		if (animals.size() > 0 && animals != NULL && id < animals.size()) {
			returnValue = (String) animals.get(id);
		}
		
		return returnValue;
	} // end getAnimalNameById method
    
} // end AnimalLocator class

I would appreciate your help in this post.

Thank you,

Sinan
Got this error & just following directions...

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: HQVTALII

It is a brand new org.
I was wondering if anyone has had any experience assigning a Topic to a record from the Question object before.

Some background
We are currently buiding a custom site using VisualForce and custom JS to essentially provide our own interface to the standard SF community functionality.

The page I'm currently working on is our Q&A page - specifically the page through which customers can post their own Questions to our customer community.

The Goal
The issue is, we need to be able to filter our questions by topic - not just by data category.  This must also be achieved purely in APEX without any standard apex components on the VF page.

What has been done so far
So far, I have enabled topics for the question object (under Topics for Objects in SF setup).  I have enabled system permissions for the appropriate profiles to create, edit, and assign topics.  Yet I keep running into an apex exception when I try to assign the topic to the question.

Attempt 1: Manually insert a record into the TopicAssignment object
In the code, I create and insert a question (and topic if required).  This works without any problems.  Then I run the following:
TopicAssignment a = new TopicAssignment(TopicId=t.Id, EntityId=q.Id, NetworkId=n.Id);
insert a;
This line will throw the following error:
Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Entity ID: id value of incorrect type: 906N00000004EF7IAM: [EntityId]
Attempt 2:  Use the ConnectApi
I then found a new class in the ConnectApi called Topics which does not yet appear to be documented.
ConnectApi.Topics.assignTopic(networkId question.Id, topic.Id);
Using this instead yields the following error:
Failed to assign topic to 906N00000004EFC. Please ensure you have permissions to assign topics for this record.


Both of the above errors still occur if the class has sharing off - e.g.
public without sharing class ClassName {
}



I am hoping to achieve this without having to create a new object as a workaround.

So, I was wondering if anyone else has had this issue?  Has anyone succesfully assigned a topic to a question in pure APEX?  Can anyone help?

Thank you very much,

Nic



 
Dear all,

For 2 days, I have been having the following issue : all the automatical emails my team and I usually receive from Salesforce (e.g. emails when a big opportunity is won, emails when I am trying a new email template and sending me a test email to preview the result...) are sent with a few hours of delay (usually at the end of the day).

So I tried the email deliverability test and I only received ~20 of the 32 emails I should have received.

Do you have any idea on why this is happening ?

Thanks in advance,
Yannick
Is this happening to you? You're 100% sure you've done a Trailhead challenge right, but it just won't validate?

So here's the deal. We're doing a real-time API call to check your work, and sometimes, there might be existing configuration or code in your Developer Edition that interferes with our check, causing it to fail.

The best thing to do if you're 100% sure you're right is create a new Developer Edition and do the challenge again.

But wait, what about my badges?

No worries! Logging into Trailhead is a two-step process. Check out this image.

The login button is in the upper right, and the second login is on the unit page right before you do the challenge

In step (1), you tell Trailhead who you are. This is where your badges are stored. You can use your production username or any Developer Edition username for this step.

In step (2), you tell Trailhead where you're doing the challenge. This must be a Developer Edition.

Okay, I got the new DE. Now what?

So, just stay logged in at (1), and make a new Developer Edition to log in at (2). Do the challenge in the new Developer Edition and check it.

If it passes, it was probably something funky in your old DE. If it fails, time to revisit your challenge! Read the instructions again and make sure you didn't miss any steps.

But why would this happen?

It could be your DE is older, or it could be you've done some additional config or customization that is interfering with our check. 

Good luck!
There is a permission page after community user login via mobile app which we created with native SF SDK. The wording "否允存取" in the permission page is very strange in Chinese locale. I don't understand the meaning of "否允存取" even I speak in Chinese for 30 years. Is there a way we can edit the wording or removing the page!? Actually our client owns the APP, the SF org and all member data so we don't need the permission page at all.
HI Experts,

while posting my code in developers community, getting this error what does it mean by."The operation is not permitted. If you received this in error, please contact info@developerforce.com (code: B2)"
I am working on a project to create a VF page where the user can add multiple attachments when creating a record.  Someone suggested the controller listed below, and while it will save the attachments, it isn't saving any of the information entered in the VF page for the Incident Report.  If anyone can take a look at this and tell me why the Incident Report isn't being saved, I would truly appreciate it.

APEX CLASS
 
public class AddMultipleAttachments {
    
    public Incident_Reports__c objIncidentReport { get; set; }
    public Attachment attachment1 { get; set; }
    public Attachment attachment2 { get; set; }
    public Attachment attachment3 { get; set; }

    public AddMultipleAttachments (ApexPages.StandardController stdController)
    {
        // Record and Attachments to be inserted
        objIncidentReport = new Incident_Reports__c();
        attachment1 = new Attachment();
        attachment2 = new Attachment();
        attachment3 = new Attachment();
    }

    public PageReference createRecordAndAttachments()
    {
        
        Savepoint sp = Database.setSavepoint();
        try
        {
            // Insert the record
            insert objIncidentReport;

        
            // Insert Attachments;
            List<Attachment> toInsert = new List<Attachment>();

            if(attachment1.Name != null)
            {
                attachment1.ParentId = objIncidentReport.Id;
                toInsert.add(attachment1);
            }
            
            if(attachment2.Name != null)
            {
                attachment2.ParentId = objIncidentReport.Id;
                toInsert.add(attachment2);
            }

            if(attachment3.Name != null)
            {
                attachment3.ParentId = objIncidentReport.Id;
                toInsert.add(attachment3);
            }

            if(toInsert.size() > 0)
                insert toInsert;
        }
        catch(Exception ex)
        {
            Database.rollback(sp);
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, ex.getMessage());
            ApexPages.addMessage(msg);
        }

        // View the record
        PageReference page = ApexPages.currentPage();
        page.setRedirect(true);
        return page;
    }

}

Here is the Visualforce page:

Visualforce Page
 
<apex:page standardController="Incident_Reports__c" extensions="AddMultipleAttachments">
    
    <apex:sectionHeader title="Property Incident Reports Edit" subtitle="{!Incident_Reports__c.Name}"/>
    <apex:form >
        
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Save with Attachments" action="{!createRecordAndAttachments}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>
        <apex:pageBlock title="Property Incident Reports Edit" mode="edit" id="thePageBlock">
          <apex:pagemessages />
            
            <apex:pageBlockSection columns="1">
              <apex:outputText value="ATTENTION:  Attorney work product/privileged document (for internal use only).  NOT for Associate Injuries, use Worker's Comp Incident Report." style="font-weight:800"/>
              <apex:outputText value="RED LINES REPRESENT REQUIRED FIELDS" style="color:red"  />
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Property Information" columns="2">
                <apex:inputField value="{!Incident_Reports__c.Property__c}" required="true"/>
                
            </apex:pageBlockSection>
               
            <apex:pageBlockSection title="Claimant Information" columns="2">
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Name__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Gender__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Address__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Age__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Date_of_Birth__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Phone_Number__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Phone_Number_Other__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Claimant_s_Occupation__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Alliance_Associate__c}" required="false"/>
            </apex:pageBlockSection>  
                          
        </apex:pageBlock>
            
       
        
       <apex:pageBlock title="Incident Information" mode="edit" id="Incident">
            
          <apex:actionRegion >
            <apex:pageBlockSection title="Incident Type" columns="1">
              <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Type of Incident"/>
                    <apex:outputPanel >
                      <apex:inputField value="{!Incident_Reports__c.Type_of_Incident__c}" required="TRUE">
                        <apex:actionSupport event="onchange" rerender="Incident" status="IncidentType"/>
                      </apex:inputField>
                      <apex:actionStatus startText="applying value..." id="IncidentType"/>
                    </apex:outputPanel>
                  </apex:pageBlockSectionItem> 
            </apex:pageBlockSection>
          </apex:actionRegion>

          <apex:actionRegion >
            <apex:pageBlockSection title="Incident Information" columns="2">     
                <apex:inputField value="{!Incident_Reports__c.Date_Time_of_Incident__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Date_Time_Incident_Reported__c}" required="false"/> 
                <apex:inputField value="{!Incident_Reports__c.Pictures_Attached__c}" required="false"/>
                <apex:inputField value="{!Incident_Reports__c.Property_Owner_Notified__c}" required="false"/> 
                
                <apex:pageBlockSectionItem helpText="Check this box if Police, Fire or Ambulance were dispatched to the property.">
                    <apex:outputLabel value="Emergency Services Called"/>
                    <apex:outputPanel >
                      <apex:inputField value="{!Incident_Reports__c.Emergency_Services_Required__c}" label="Check if Police, Fire or Ambulance were dispatched to the property.">
                        <apex:actionSupport event="onclick" rerender="Incident" status="status"/>
                      </apex:inputField>
                      <apex:actionStatus startText="applying value..." id="status"/>
                    </apex:outputPanel>
                  </apex:pageBlockSectionItem>  
            </apex:pageBlockSection>
            
          </apex:actionRegion>
          
          <apex:actionRegion >
            <apex:pageBlockSection title="Responding Agencies" id="agencies" columns="2" rendered="{!Incident_Reports__c.Emergency_Services_Required__c == TRUE}">
              
              
              <apex:pageBlockSectionItem >
               
              <apex:outputLabel value="Police Department"/>
              <apex:outputPanel >
                <apex:inputField value="{!Incident_Reports__c.Police_Responded__c}">
                <apex:actionSupport event="onclick" rerender="Incident" status="status1"/>
              </apex:inputField>
              <apex:actionStatus startText="adding Police Department block..." id="status1"/>
              </apex:outputPanel>
              </apex:pageBlockSectionItem>
              
              <apex:pageBlockSectionItem >
               
              <apex:outputLabel value="Fire Department"/>
              <apex:outputPanel >
                <apex:inputField value="{!Incident_Reports__c.Fire_Department_Responded__c}">
                <apex:actionSupport event="onclick" rerender="Incident" status="status2"/>
              </apex:inputField>
              <apex:actionStatus startText="adding Fire Department block..." id="status2"/>
              </apex:outputPanel>
              </apex:pageBlockSectionItem>
              
              <apex:pageBlockSectionItem >
               
              <apex:outputLabel value="Ambulance Service"/>
              <apex:outputPanel >
                <apex:inputField value="{!Incident_Reports__c.Ambulance_Company_Responded__c}">
                <apex:actionSupport event="onclick" rerender="Incident" status="status3"/>
              </apex:inputField>
              <apex:actionStatus startText="adding Ambulance Service block..." id="status3"/>
              </apex:outputPanel>
              </apex:pageBlockSectionItem>
              
              <apex:pageBlockSectionItem >
               
              <apex:outputLabel value="Other Emergency Service"/>
              <apex:outputPanel >
                <apex:inputField value="{!Incident_Reports__c.Other_Department_Responded__c}">
                <apex:actionSupport event="onclick" rerender="Incident" status="status4"/>
              </apex:inputField>
              <apex:actionStatus startText="adding Other Emergency Service block..." id="status4"/>
              </apex:outputPanel>
              </apex:pageBlockSectionItem>
              
            </apex:pageBlockSection>
          </apex:actionRegion>
            
            <apex:pageBlockSection title="Police Department Information" id="police" columns="2" rendered="{!Incident_Reports__c.Police_Responded__c == TRUE}">
                <apex:inputField value="{!Incident_Reports__c.Police_Department_Name__c}" label="Police Department Name"/>
                <apex:inputField value="{!Incident_Reports__c.Police_Report_Number__c}" label="Police Report Number"/>
                
                                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Fire Department Information" columns="2" rendered="{!Incident_Reports__c.Fire_Department_Responded__c == TRUE}">
                <apex:inputField value="{!Incident_Reports__c.Fire_Department_Name__c}" label="Fire Department Name"/>
                <apex:inputField value="{!Incident_Reports__c.Fire_Dept_Report_Number__c}" label="Fire Dept. Report Number"/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Ambulance Information" columns="2" rendered="{!Incident_Reports__c.Ambulance_Company_Responded__c == TRUE}">
                <apex:inputField value="{!Incident_Reports__c.Ambulance_Company_Name__c}" label="Ambulance Company Name"/>
                <apex:inputField value="{!Incident_Reports__c.Ambulance_Company_Report_Number__c}" label="Ambulance Co. Report Number"/>
                
                <apex:inputField value="{!Incident_Reports__c.Hospital_Name__c}" label="Hospital Taken To (if applicable)"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Other Emergency Services" columns="2" rendered="{!Incident_Reports__c.Other_Department_Responded__c == TRUE}">
                <apex:inputField value="{!Incident_Reports__c.Other_Respondant__c}" label="Other Department Name"/>
                <apex:inputField value="{!Incident_Reports__c.Other_Report_Number__c}" label="Other Department Report Number"/>
                
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Moisture / Flooding" columns="3" rendered="{!Incident_Reports__c.Type_of_Incident__c == 'Flood/Moisture'}" id="FloodingSection">
                <apex:inputTextarea value="{!Incident_Reports__c.Affected_Area__c}" label="Describe Affected Area" cols="40" rows="8"/>
                <apex:inputTextarea value="{!Incident_Reports__c.Source_Cause_of_Moisture__c}" label="Describe Cause of Moisture" cols="40" rows="8"/>
                <apex:inputTextarea value="{!Incident_Reports__c.Personal_Property_Damage__c}" label="Detail Damage to Personal Property" cols="40" rows="8"/>
                <apex:inputField value="{!Incident_Reports__c.Date_Notification_Letter_Sent__c}" label="Date Notification Letter Sent"/>
                <apex:inputField value="{!Incident_Reports__c.Date_Option_Letter_Given__c}" label="Date Option Letter Given"/>
                <apex:inputField value="{!Incident_Reports__c.Date_Option_Letter_Received__c}" label="Date Option Letter Received"/>
                <apex:inputField value="{!Incident_Reports__c.Follow_Up_Call_Completed__c}" label="Date Follow-up Call Completed"/>
                <apex:inputField value="{!Incident_Reports__c.Follow_Up_Call_Associate__c}" label="Name of Associate Conducting Call"/>
                <apex:inputTextarea value="{!Incident_Reports__c.Result_of_Conversation__c}" label="Result of Conversation" cols="40" rows="8"/>
            </apex:pageBlockSection>
           
        </apex:pageBlock>
           
        <apex:pageBlock title="Add Attachments">
          	<apex:pageBlockSection title="Attachment 1" >
                <apex:inputFile value="{!attachment1.body}" fileName="{!attachment1.name}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Attachment 2" >
                <apex:inputFile value="{!attachment2.body}" fileName="{!attachment2.name}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title="Attachment 3" >
                <apex:inputFile value="{!attachment3.body}" fileName="{!attachment3.name}"/>
            </apex:pageBlockSection>
        
        </apex:pageBlock>
    </apex:form>    
</apex:page>

Again, any help is greatly appreciated.

Thanks,

Matt
I'm using AggregateResult to display 2 values, first is a sum of a custom field Hours_Used__c which is in a custom object Holiday__c. Second is a sum of a custom field Hours_Available__c which is on the User object.

I am able to show these results separately on my visualforce page shown here:

vfpage

My requirement is to be able to display Hours_Available__c - Hours_Used__c to leave me with a column that shows the Staff Member Name and the total hours that are left.

For example using the screenshot above I would need a pageblocktable that shows:

Staff Member   | Hours Left
Adam west      | 252
Duke Young     | 225
Jim Taylor       | 198

Controller:
public class HolidayManagementController {
    
    Public List<Holiday__c> HolidayList {get;set;}
    Public List<AggregateResult> HoursUsedList;
    Public List<AggregateResult> AllowanceTotalList;
 
    String cname {get;set;}
    
    Public HolidayManagementcontroller(){
        cname		= UserInfo.getUserName();
        user cu	  	= [SELECT Name FROM User WHERE username =:cname];
        
        HolidayList 		= [SELECT Hours_Used__c, Staff_Member__c, Staff__r.Name, Manager_Name__c
                               FROM Holiday__c
                               WHERE Manager_Name__c =:cu.Name
                               ORDER BY Staff__r.Name];
       
        HoursUsedList 		= [SELECT SUM(Hours_Used__c) hours, Staff__r.Name staff
                               FROM Holiday__c
                               WHERE Manager_Name__c =:cu.Name
                               GROUP BY Staff__r.Name
                               ORDER BY Staff__r.Name asc];
        
        AllowanceTotalList 	= [SELECT SUM(Hours_Available__c) allowance, Name
                              FROM User
                              WHERE Manager__c =:cu.Name
                              GROUP BY Name
                              ORDER BY Name asc];
        
    }
    
    public list<AggregateResult> HoursList {
 	get { return HoursUsedList;}
 	}
    
    public list<AggregateResult> AllowanceList {
 	get { return AllowanceTotalList;}
 	}
}

VF Page:
<apex:page controller="HolidayManagementController" sidebar="false">
    <apex:form>
        <apex:pageBlock>
			<apex:pageBlockTable value="{!HolidayList}" var="hlist">

                <apex:column headerValue="Staff Member">
                <apex:outputField value="{!hlist.Staff__r.Name}"/>
                </apex:column>

                <apex:column headerValue="Manager">
                <apex:outputField value="{!hlist.Manager_Name__c}"/>
                </apex:column>
  
                <apex:column headerValue="Hours Used">
                <apex:outputField value="{!hlist.Hours_Used__c}"/>
                </apex:column>
                
            </apex:pageBlockTable>            
        </apex:pageBlock>
        
        <apex:pageBlock>
        <apex:pageBlockTable value="{!HoursList}" var="h">
        	  
           <apex:column >
            <apex:facet name="header">Staff Member</apex:facet>
            {!h['staff']}</apex:column>
            
            <apex:column >
            <apex:facet name="header">Hours Used</apex:facet>
            {!h['hours']}</apex:column>
            

            
        </apex:pageBlockTable>
            
        <apex:pageBlockTable value="{!AllowanceList}" var="a">
        	  
           <apex:column >
            <apex:facet name="header">Staff Member</apex:facet>
            {!a['Name']}</apex:column>
            
            <apex:column >
            <apex:facet name="header">Hours Available</apex:facet>
            {!a['allowance']}</apex:column>
            

            
        </apex:pageBlockTable>    
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Any help would be greatly appreciated. I'm pretty new to programming in general so i'm open to suggesstions if i'm going about this the wrong way. 

Thanks
L
  • January 25, 2015
  • Like
  • 1
Hello,
I have a number field on my account object that if greater than 1, I want it to change the account type to "Account Active"
Account Active is currently an option under the picklist field = Type.

What I am currently doing manually is running a report that shows customers with number of subscriptions. If I see one that has 1 or more subscription I have to go and change the account type to "Active Customer" currently it just stays as "Active Prospect" which is the default field.
Is this possible to automate with a trigger?
thank you-
  • November 06, 2014
  • Like
  • 1