• pcon
  • ALL STAR
  • 14636 Points
  • Member since 2011
  • Senior Software Engineer
  • Red Hat


Badges

  • Chatter
    Feed
  • 440
    Best Answers
  • 0
    Likes Received
  • 10
    Likes Given
  • 1
    Questions
  • 3176
    Replies

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.
For fetching the sessionId, I am getting the error: Require TLS 1.1 or higher"

I checked other posts and looked for the deactivation in Critical Updates but I cannot see that option.

Can somebody help me resolve this problem?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>sf:UNSUPPORTED_CLIENT</faultcode>
         <faultstring>UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</faultstring>
         <detail>
            <sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
               <sf:exceptionCode>UNSUPPORTED_CLIENT</sf:exceptionCode>
               <sf:exceptionMessage>TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https.</sf:exceptionMessage>
            </sf:UnexpectedErrorFault>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>



This is the error.
 

We are writing an interface servlet which has data passed to it, parses the data and creates the JSON, then sends the JSON to Salesforce. I'm having an issue authenticating. My authorization is as follows:

 

public String getAuth() throws HttpException, IOException, JSONException {
    	//post.addParameter("code",code);
    	HttpClient httpClient = new HttpClient();
    	ServletConfig context = getServletConfig();
    	post = new PostMethod(context.getInitParameter("environment"));
    	
    	System.out.println("environment: " + context.getInitParameter("environment"));
    	System.out.println("clientId: " + context.getInitParameter("clientId"));
    	System.out.println("clientSecret: " + context.getInitParameter("clientSecret"));
    	System.out.println("redirectUri: " + context.getInitParameter("redirectUri"));

    	
        post.addParameter("grant_type","authorization_code");
        post.addParameter("client_id",context.getInitParameter("clientId"));    	
    	post.addParameter("client_secret",context.getInitParameter("clientSecret"));
    	post.addParameter("redirect_uri",context.getInitParameter("redirectUri"));
    	   
    	httpClient = new HttpClient();
    	httpClient.executeMethod(post);
   
    	String responseBody = post.getResponseBodyAsString();
    	
    	System.out.println("response body: " + responseBody);
    	   
    	JSONObject json = null;
    	json = new JSONObject(responseBody);
    	String accessToken = json.getString("access_token");
        //String issuedAt = json.getString("issued_at");
              
       /*HttpServletResponse httpResponse = (HttpServletResponse)response;
       Cookie session = new Cookie("ACCESS_TOKEN", accessToken);
       session.setMaxAge(-1); //cookie not persistent, destroyed on browser exit
       httpResponse.addCookie(session);*/
        
       return accessToken;
    }

I recieve this error back:

{"error":"invalid_grant","error_description":"invalid authorization code"}
I currently have "code" commented out, because I'm not exactly clear on the flow of things. The documentation says you get the authorization code from the redirect_url, but I'm not redirecting to anything, just connecting with this Java servlet. Is there a better way of doing this? Or am I even doing it correctly to start with? Any help would be appreciated.
Hi all,

I'm having some trouble figuring out how to delete a custom object record. I use the same code as provided in this article: Interact with the Force.com REST API with PHP
 
function delete_qce_part ($id, $instance_url, $access_token) {
    $url = "$instance_url/services/data/v37.0/sobjects/QCE_Part__c/$id";

    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token"));
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
    
    curl_exec($curl);
    
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if ( $status != 204 ) {
        die("Error: call to URL $url failed with status $status, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
    }

    echo "HTTP status $status deleting part<br/><br/>";

    curl_close($curl);
    return $result;
}

I get an error message with that "METHOD_NOT_ALLOWED, HTTP Method 'DELETE' not allowed. Allowed are HEAD,GET,POST", "Error: call to URL [URL to Sandbox] failed with status 405, curl_error , curl_errno 0"

Any assistance in resolving this error would be greatly appreciated.
Hi
I am doing the trailhead learnings and need to refresh my data in force.com to do the tests in Trailhead. How can I refresh my force.com data back to the initial start (when creating first time a test account)
Hi friends,

I have a requirement to integrate with gmail from salesforce, Requirement is i will have a custom button on object detail page
when i click on the button gmail compose page should be opened and automatically attachment should be attached to Gmail compose page.
Attachment can be a vf page Pdf which we will generate on the fly or we will take from attachment.

Please let us know solution on this.


Thanks,
Shiva

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
We implemented inbound REST API in Salesforce. We were able to test the API through POSTMAN using OAuth token. All of a sudden, we are  receiving mutual authentication error. Not sure why we are getting mutual authentication when i use OAuth token. Can anyone help on this?
 {
        "message": "This session could not be mutually authenticated for use with the REST API",
        "errorCode": "MUTUAL_AUTHENTICATION_FAILED"
    }
Hello everyone,
I have a page on facebook where I need to verify my domain (site) from force.com.

I'm trying to follow these steps from facebook:
(https://developers.facebook.com/docs/sharing/domain-verification)
Log in to the domain and visit the DNS records section.
Add this TXT record to your DNS configuration:
facebook-domain-verification = me5ndc38794385kh9ysd9wj7rayhim
Add @ in the Host field (if your domain host requires it)
Wait until your DNS configuration changes spread to your site's domain servers (this may take up to 72 hours and you click Verify.

However, I can't find where are the options to configure the DNS TXT Records on Salesforce.

Can anyone help me with that?
Technology company utilizes a custom proprietary web-based platform to generate a lead, registrations, contacts into a SQL database.

What is the best and most efficient way to connect the SQL database with Salesforce 

Key is that when fields or a key event in SQL DB are updated they are updated in SFDC.
<apex:variable var="publicVisible" value="Public to Customers"/>  
                 <apex:pageBlockTable value="{!case.IPS_Case_Attachments__r}" var="att" rendered="{!externalUser}">



In the same way I want to create three more variables for multiple render conditions like AND,OR
I want to Create a SOQL Query to get the Count of number of Opportunity Records & update in child Object Field
Hi 
I have a requirement Where i want to Query the Records based on the Below Criteria :
Account_Executive is  a Custom Field(User Lookup) field whenever i select a User in Account_Executive field  in Territory_plan__c (object) it should query all the Records of event related to Opportunity  & update in  #of ONsite at xyz - in progress .
#of ONsite at xyz - in progress  : Is a field on Custom Object(Territory_plan__c ) where i want to Update the Count of below criteria

# of Onsite at xyz– In Progress
This field should populate with the number of Opportunity records that meet the following criteria:
The User in the “Account Executive” field in the Territory Plan object is equal to the “Assigned To” in the Event object
The Status for the Event is “Scheduled”
The Type for the Event is “On-Site at xyz”
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
@AuraEnabled  
  public static List<String> setMensagem(String msgInfo, ApexPages.Severity aSeverity){
      
 		 //ApexPages.Message msg = new ApexPages.Message(aSeverity, msgInfo);
    	 //ApexPages.addMessage(msg);msgInfo 
        List<String> lErros = new List<String>();
        lErros.add(msgInfo);
      
      	return lErros;
     
  }

I want to use errors in lightning.
Hi All,

Please help me on below issue.


1. Trigger will work on user mode or system mode
2. In below class account is having one contact but one user able to see contact another user not why another user not able to see contact please help me.

3. As per my knowledge below class will work on system mode.
4. Please help me why another user not ble to see the contact.
 
trigger sampleTrigger on account(after update){
  AccountHelper.Createcontact(Trigger.new);
}

If account type == hot then i need create one conatct for account only one contact.
If contact is existing then no need to crete contact.

public class AccountHelper{

 public static void Createcontact(list<account> accs){
  set<id> acciDs = new set<id>(); 
  for(account acc : accs){
   if(acc.type == 'hot'){    
      acciDs.add(acc.id);   
   } 
 }
 list<account> accslist = [select id,name,(select id from contacts) from acount];
 
 for(account acc : accslist){
     if(acc.contacts.size()== 0){
	 
	    //crating contact here 
	 }
 
 }
}

 
Hi all,
How can we say like particular trigger context variable is present in particular  trigger event? could anyone explain me in brief (logically)

eg: new : 
This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
we know that 
new Returns a list of the new versions of the sObject records.
generally we will get new verisonas of records when we update or when insert or when we undelete...
like above 
could anyone give me the explanation for remaining
@isTest
public class MaintenanceRequestTest {
	@isTest
    static void testMaintenanceRequest(){
        
        List<Case> caseList = new List<Case>();

        Product2 prod = new Product2();
        prod.Cost__c = 50;
        prod.Name = 'Ball Valve 10 cm';
        prod.Lifespan_Months__c = 12;
        prod.Maintenance_Cycle__c = 365;
        prod.Current_Inventory__c = 50;
        prod.Replacement_Part__c = true;
        prod.Warehouse_SKU__c = '100009';
        insert prod;
        System.assertEquals(1, [SELECT count() FROM Product2 WHERE Name = 'Ball Valve 10 cm']);
            
         for(Integer i=1;i<=200;i++) {
            Case caseNew = new Case();
            caseNew.Subject = 'Maintenance';
            caseNew.Type = 'Other';
            caseNew.Status = 'New';
            caseNew.Equipment__c = caseNew.Id;
            caseList.add(caseNew);   
        }
        
        Test.startTest();
        
        insert caseList;
        System.assertEquals(200, [SELECT count() FROM Case WHERE Type = 'Other']);
        
        for(Case a : caseList){
            a.Type = 'Repair';
            a.Status = 'Closed';
        }
		update caseList;
        System.assertEquals(200, [SELECT count() FROM Case WHERE Type = 'Repair']);
        
        Test.stopTest();
        
    }
}




public class MaintenanceRequestHelper {
    
    public static void updateWorkOrders(Map<Id, Case> applicableCases){

	    Map<Id, Integer> mapProduct = new Map<Id, Integer>(); 
   		List<Case> newCases = new List<Case>();
        
        List<Product2> listProduct = [select Id, Maintenance_Cycle__c from Product2];       							
		for (Product2 p : listProduct) {
            if (p != null) {
                if(p.Maintenance_Cycle__c != null){
                    mapProduct.put(p.Id, Integer.valueOf(p.Maintenance_Cycle__c));
                }               
            }
        }

        for(Case a: applicableCases.values()){
            Case newCase = new Case();
            newCase.Vehicle__c = a.Vehicle__c;
            newCase.Equipment__c = a.Equipment__c;
            newCase.Type = 'Routine Maintenance';
            newCase.Subject = String.isBlank(a.Subject) ? 'Routine Maintenance Request' : a.Subject;
            newCase.Date_Reported__c = Date.today();
            newCase.Status = 'New';
            newCase.Product__c = a.Product__c;
            newCase.AccountId = a.AccountId;
            newCase.ContactId = a.ContactId;
            newCase.AssetId = a.AssetId;
            newCase.Origin = a.Origin;
            newCase.Reason = a.Reason;
            newCase.Date_Due__c =  (mapProduct.get(a.Id) != null) ? (Date.today().addDays(Integer.valueOf(mapProduct.get(a.Id)))) : (Date.today());
            newCases.add(newCase);
        }
        if(newCases.size() > 0){
            insert newCases;
        }
		        
        
    }        
    
}




trigger MaintenanceRequest on Case (before update, after update) {
    // call MaintenanceRequestHelper.updateWorkOrders  
    // 
    Map<Id,Case> applicableCases = new Map<Id,Case>();
    
    if(Trigger.isUpdate  && Trigger.isAfter){
        for(Case oCase: Trigger.new){
            if (oCase.IsClosed && (oCase.Type.equals('Repair') || oCase.Type.equals('Routine Maintenance'))){
                applicableCases.put(oCase.Id, oCase);
            }
        }
        if(!applicableCases.values().isEmpty()){
        	MaintenanceRequestHelper.updateWorkOrders(applicableCases);    
        }        
    } 
}

I got 100% code covergae. but i couldn't clear this challenge. the following is the error im getting when i check the challenge.
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Case: id value of incorrect type: 01t7F000003BjDmQAK: [Equipment__c].   

Can anyone please help me to fix this issue?
Hi All,

I am trying to parse below XML to get value of <state>RUNNING</state>. But it is giving null. I am using system.debug(document.getRootElement().getChildElement('return', null));

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header />
   <env:Body>
      <ns2:getOutboundCampaignResponse xmlns:ns2="http://service.admin.ws.five9.com/">
         <return>
            <description>1 - 14 Days Past Due</description>
            <mode>ADVANCED</mode>
            <name>Arrangements 1-14 TEST</name>
            <profileName>Arrangements</profileName>
            <state>RUNNING</state>
            <trainingMode>false</trainingMode>
            <type>OUTBOUND</type>
            <autoRecord>true</autoRecord>
            <callWrapup>
               <enabled>false</enabled>
            </callWrapup>
            <ftpHost />
            <ftpPassword />
            <ftpUser />
            <recordingNameAsSid>false</recordingNameAsSid>
            <useFtp>false</useFtp>
            <analyzeLevel>20</analyzeLevel>
            <CRMRedialTimeout>
               <days>0</days>
               <hours>1</hours>
               <minutes>0</minutes>
               <seconds>0</seconds>
            </CRMRedialTimeout>
            <dnisAsAni>false</dnisAsAni>
            <enableListDialingRatios>false</enableListDialingRatios>
            <listDialingMode>LIST_PENETRATION</listDialingMode>
            <noOutOfNumbersAlert>false</noOutOfNumbersAlert>
            <stateDialingRule>FOLLOW_STATE_RESTRICTIONS</stateDialingRule>
            <timeZoneAssignment>INHERIT_DOMAIN_SETTINGS</timeZoneAssignment>
            <actionOnAnswerMachine>
               <actionType>DROP_CALL</actionType>
            </actionOnAnswerMachine>
            <actionOnQueueExpiration>
               <actionType>DROP_CALL</actionType>
            </actionOnQueueExpiration>
            <callAnalysisMode>FAX_AND_ANSWERING_MACHINE</callAnalysisMode>
            <callsAgentRatio>1.0</callsAgentRatio>
            <dialNumberOnTimeout>true</dialNumberOnTimeout>
            <dialingMode>PROGRESSIVE</dialingMode>
            <dialingPriority>3</dialingPriority>
            <dialingRatio>50</dialingRatio>
            <distributionAlgorithm>MinHandleTime</distributionAlgorithm>
            <distributionTimeFrame>minutes30</distributionTimeFrame>
            <limitPreviewTime>true</limitPreviewTime>
            <maxDroppedCallsPercentage>3.0</maxDroppedCallsPercentage>
            <maxPreviewTime>
               <days>0</days>
               <hours>0</hours>
               <minutes>2</minutes>
               <seconds>0</seconds>
            </maxPreviewTime>
            <maxQueueTime>
               <days>0</days>
               <hours>0</hours>
               <minutes>0</minutes>
               <seconds>1</seconds>
            </maxQueueTime>
            <monitorDroppedCalls>true</monitorDroppedCalls>
            <previewDialImmediately>false</previewDialImmediately>
            <useTelemarketingMaxQueTimeEq1>false</useTelemarketingMaxQueTimeEq1>
         </return>
      </ns2:getOutboundCampaignResponse>
   </env:Body>
</env:Envelope>

Please help

Regards
Madhusudan Singh
trigger Giveendclientname on Lead (before insert, before update) {
    List<ID> OppIds = New List<ID>();
    for(lead ld : Trigger.new){
        if(ld.Customer_Type__c == 'partner'){
            OppIds.add(ld.Customer_Type__c);
        }
        List<Opportunity> oppList = [SELECT id, EndClientName__c FROM Opportunity WHERE id in :OppIds];
    //    for(Lead opp : trigger.new){
            if(oppList.EndClientName__c == ''){
                //  oppList[i].status = 'Approved';
                oppList.addError('End client name should be given if it is a partner Account');
            }
           // oppList.add(opp);
            update oppList;
      //  }
    }
}

The requirement is, when the customer type in lead is partner, then the endclient name in opportunity should not be blank. it should throw an error.
<apex:page>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="  crossorigin="anonymous"></script>
    
    <script>
    
        function Callout()
        {
            var JSONResponse = '';
            var JsonBody = '';
            JsonBody = '{"capital ": "delhi"}';
            
            
            
            
            console.log('--JsonBody ------->'+JsonBody );
            
            var xhr = new XMLHttpRequest();
            xhr.open("POST", "http://myendpointxxxxr", true);
            <!-- xhr.setRequestHeader("Authorization","Bearer {!AccessToken}" ); -->
            xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
            
            xhr.onload = function () 
            {
                JSONResponse = xhr.responseText;
                console.log('--JSONResponse ------->'+xhr.responseText);
            };
            xhr.send(JsonBody);
            setTimeout( function()
                {
                    if(xhr.status == 404){                     
                    }
                    else if(xhr.status == 401){
                    }
                    else if(xhr.status == 500){
                    }
                    else if(xhr.status == 200)
                    {
                        obj1 = JSON.parse(JSONResponse );
                        for(var x=0;x< obj1.length;x++)
                        {
                            var singleEle = obj1[x];
                            console.log('--singleEle ------->'+singleEle );
                        }
                    }
                },
            2000);
        }
        
    </script>   
    
    <apex:form>
        <apex:pageBlock>
             <apex:pageBlockButtons location="Top">
                <button type="button" onclick="Callout();" style="height:22px; width:150px" > 
     Make Callout 
                </button>
             </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

iam getting the below errror :Failed to load resource: the server responded with a status of 404 (Not Found). any wrong in the code
Hi All,

I am unable to create case to the salesforce and getting the below exception.

2018-05-08 10:45:02,476 [9] ERROR Vielife.SalesForce.SalesForceWraper [(null)] - System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Vielife.SalesForce.SforceService.login(String username, String password)
   at Vielife.SalesForce.SalesForceWraper.Login()
Hi, 
My requirement is to show a link to an attachment in edit and create page.
I have created formula hyperlink field it displays only in detail page, I want the link to be displayed in create and edit page.
I know formula fields does not support in edit and create page, is there any way to add a link in these pages.
I don't want override edit and create pages through VF page, I want to achieve in standard pages only.

Regards,
Sandhya S P
related to this https://help.salesforce.com/articleView?id=000229717&type=1
Is SForceOfficeToolkitLib4.SForceSession4 still supported.
I changed the URL to g_sfApi.SetServerUrl "https://login.salesforce.com"
but getting the following error message
SFWinInet::Send::HttpSendRequestEx
Win32Error::
An error occurred in the secure channel support
  • May 08, 2018
  • Like
  • 0
Hi SalesforceTeam,  

Could you please let us know about the integration/deployment process of third-party chatbots like IBM Watson, Kore.ai, LUIS, etc.. inside Salesforce.

Thanks,
Vignesh
Here is my apex class which is call from custom button contan javascript code
global class CreateOpty{

WebService static String CreateOptywithps(String Id)
{
List<Patient_Services__c> ps= new List<Patient_Services__c>();
List<Rate_Card__c> rcard=new List<Rate_Card__c>();
List<sked__Job__c> joblist=new List<sked__Job__c>();
List<sked__Job__c> joblistnw=new List<sked__Job__c>();
Set<OpportunityLineItem> olilist=new Set<OpportunityLineItem>();
List<OpportunityLineItem> olilist1=new List<OpportunityLineItem>(); 
List<Opportunity> oplist=new List<Opportunity>();
List<Account> accname = new List<Account>();
Integer extid;
String RecNamePodwP,RecNameAudwP,RecNameDiteticscwP,RecNameDivTrpwP,RecNameMntHlthwP,RecNameOccTrpwP,RecNameOptmwP,RecNamePhytrpwP,RecNamePhyTrpExClswP,RecNameRegNrsewP,RecNameSpchTrpwP;
String myeffDate = date.today().format();
Date Nxtoptycreationdate,Closedate;
String BillableCycle,InvoiceSentby,InvoiceSentTo,Accntterms,RateCardtype;
List<Patient_Services__c> psupdlist= new List<Patient_Services__c>();
Map<String, Schema.SObjectType> sObjectMap = Schema.getGlobalDescribe() ;
Map<String,Schema.RecordTypeInfo> recordType = sObjectMap.get('Opportunity').getDescribe().getRecordTypeInfosByName();
ID RtIdPodwP,RtIdAudwP,RtIdDiteticscwP,RtIdDivTrpwP,RtIdMntHlthwP,RtIdOccTrpwP,RtIdOptmwP,RtIdPhytrpwP,RtIdPhyTrpExClswP,RtIdRegNrsewP,RtIdSpchTrpwP;

User vLstUserop = [select id from User where Opportunity_Owner__c=true and IsActive=true LIMIT 1];

ps=[select id,Medicare_Account__c,Emergency_Visit__c,DVA_Code__c,Patient_DVA_Number__c,Patient_Medicare_No__c,Podiatry_Services__c,Job_Start_Datew_otime__c,Dispensing_Footwear_F049__c,DVA_Account__c,Initial_Consultation__c,Subsequent_Consulation__c,RecordType.name,Patient__r.Medicare_Account__c,Patient__r.Medicare_Account__r.Name,Patient__r.DVA_Account__c,Patient__r.DVA_Account__r.Name,Who_to_Invoice__c,Patient_Service_Lunch__c,Patient_Service_Invoice_Duration__c,Job_allocation_count__c,Job_Invoice_Start__c,Job_Invoice_Finish__c,Lunch_Break_Duration_from_Job__c,Job_Billable__c,Job__c,Patient_Service_Invoice_Finish__c,Patient_Service_Invoice_Start__c,Job_Type__c,Resource_Name__c,Service_Type__c from Patient_Services__c where id=:ID ];

joblistnw=[Select id,name,Facility_Patient_Sevices_Count__c,Day_count__c,Added_to_Opportunity__c,Opportunity_Id__c,Job_Start_Datew_otime__c,Job_Finish_Datew_otime__c,Lunch_Break_Duration__c,Job_Invoiced__c,sked__Type__c,sked__Account__c,
Resource_Name__c,sked__Job_Allocation_Count__c,Invoice_Finish__c, Invoice_Duration__c,
Invoice_Start__c,Job_Billable__c,sked__Duration__c from sked__Job__c 
where id=:ps[0].Job__c];

String medaccId = ps[0].Patient__r.Medicare_Account__c;
String MedaccName=ps[0].Patient__r.Medicare_Account__r.Name;
String DVAaccId = ps[0].Patient__r.DVA_Account__c;
String DVAaccName=ps[0].Patient__r.DVA_Account__r.Name;

// Check Record type and assing Id and Name to Variable
if(ps[0].RecordType.name =='Podiatry')
{     RtIdPodwP = recordType.get('Podiatry with Patients').getRecordTypeId();
	  RecNamePodwP=recordType.get('Podiatry with Patients').getName();
}
else if(ps[0].RecordType.name =='Audiology')
     {	RtIdAudwP = recordType.get('Audiology with Patients').getRecordTypeId();
        RecNameAudwP=recordType.get('Audiology with Patients').getName();
      }
	  
else if(ps[0].RecordType.name =='Dietetics')
    {		RtIdDiteticscwP = recordType.get('Dietetics with Patients').getRecordTypeId();
           RecNameDiteticscwP=recordType.get('Dietetics with Patients').getName();
    }
	
else if(ps[0].RecordType.name =='Diversional Therapy')
    { 	RtIdDivTrpwP = recordType.get('Diversional Therapy with Patients').getRecordTypeId();
        RecNameDivTrpwP=recordType.get('Diversional Therapy with Patients').getName();
    }
	
if(ps[0].Who_to_Invoice__c=='Medicare Account')
    {
    rcard=[Select id,Next_Opportunity_Creation_Date__c,Which_Rate_to_use_withpatients__c,Footwear_Dispensed__c,Emergency_Visit__c,PricebookEntryId__c,Job_Type__c,Assessment__c,Travel__c,Report__c,Treatment_Rate__c,Menu_Review__c,Hourly_Rate__c,Other__c,Next_Billable_Date__c,Opportunity_Creation_Frequency__c,Invoice_sent_by__c,Invoice_sent_to__c,Account_Terms__c,Rate_Card_Type__c from Rate_Card__c where Account_Name__c='Department of Human Services' AND Job_Type__c=:ps[0].Job_Type__c AND Rate_Card_Type__c=:ps[0].Service_Type__c ];
    }
else
    {
    rcard=[Select id,Next_Opportunity_Creation_Date__c,Which_Rate_to_use_withpatients__c,Footwear_Dispensed__c,Emergency_Visit__c,PricebookEntryId__c,Job_Type__c,Assessment__c,Travel__c,Report__c,Treatment_Rate__c,Menu_Review__c,Hourly_Rate__c,Other__c,Next_Billable_Date__c,Opportunity_Creation_Frequency__c,Invoice_sent_by__c,Invoice_sent_to__c,Account_Terms__c,Rate_Card_Type__c from Rate_Card__c where Account_Name__c='Department of Veteran Affairs' AND Job_Type__c=:ps[0].Job_Type__c AND Rate_Card_Type__c=:ps[0].Service_Type__c];
    }
    
List<Opportunity> opty=[select Id,Opty_No__c from Opportunity order by CreatedDate DESC limit 1];
for(Opportunity oppty:opty)
    {
    extid=Integer.valueOf(oppty.Opty_No__c)+1;
    }
    
	//Create opportunity and opportunity line item
    if(rcard.size()>0 && joblistnw.size()>0 && ps.size()>0)
    {
    Opportunity newopp =new Opportunity();
    if(ps[0].Who_to_Invoice__c=='Medicare Account')
    newopp.Optycreationbatch__c='Medicare-WP-'+myeffDate+'-'+extid;
    if(ps[0].Who_to_Invoice__c=='DVA Account')
     newopp.Optycreationbatch__c='DVA-WP-'+myeffDate+'-'+extid;
     if(ps.size()>0)
        {
				for(Patient_Services__c pslines:ps)
              {
              OpportunityLineItem oli = new OpportunityLineItem();
						oli.Opportunity =new Opportunity(Optycreationbatch__c=newopp.Optycreationbatch__c);
                        oli.PriceBookEntryId = rcard[0].PricebookEntryId__c;
                        oli.Patient_Service__c=pslines.Id;
                        oli.Provider_Name__c=pslines.Resource_Name__c;
                        oli.Patient_Service_Invoice_Start__c=pslines.Patient_Service_Invoice_Start__c;
                        oli.Patient_Service_Invoice_Finish__c=pslines.Patient_Service_Invoice_Finish__c;
                        oli.Rate_Card__c=rcard[0].Id;
                        oli.UnitPrice = rcard[0].Hourly_Rate__c;
                        oli.Quantity = pslines.Job_allocation_count__c;
                        oli.Patient_Service_Lunch__c=pslines.Patient_Service_Lunch__c;
                        oli.Invoice_Start__c=pslines.Job_Invoice_Start__c;
                        oli.Invoice_Finish__c=pslines.Job_Invoice_Finish__c;
                        oli.Lunch_Break_Duration_from_Job__c=pslines.Lunch_Break_Duration_from_Job__c;
                        oli.DVA_Code__c=pslines.DVA_Code__c;
                        oli.AHP_Type__c=pslines.Podiatry_Services__c;
                    
                     if(pslines.Job_Billable__c ==true)
                     {
                        oli.Job_lkup__c=pslines.Job__c;
                        if(pslines.Emergency_Visit__c == true)
                        {
                            oli.UnitPrice = rcard[0].Emergency_Visit__c;
                            oli.Quantity = pslines.Job_allocation_count__c;
                        }
                          if(pslines.Dispensing_Footwear_F049__c == true)
                        {
                            oli.UnitPrice = rcard[0].Footwear_Dispensed__c;
                            oli.Quantity = pslines.Job_allocation_count__c;
                        }
                         if(pslines.Who_to_Invoice__c=='DVA Account' && pslines.Service_Type__c=='Podiatry' && pslines.Initial_Consultation__c==true && pslines.Subsequent_Consulation__c==true)
                        {
                              oli.UnitPrice = rcard[0].Assessment__c;
                              oli.Quantity = pslines.Job_allocation_count__c;
                        }
                     else
                        {   
                            if(rcard[0].Which_Rate_to_use_withpatients__c=='Always use Treatment Rate')
                             {
                                 oli.UnitPrice = rcard[0].Treatment_Rate__c;
                                 oli.Quantity = pslines.Job_allocation_count__c;
                             }
                           else if(rcard[0].Which_Rate_to_use_withpatients__c=='Always use Menu Review Rate')
                             {
                                 oli.UnitPrice = rcard[0].Menu_Review__c;
                                 oli.Quantity = pslines.Job_allocation_count__c;
                             }
                        }                       
                    }
                     else
                     {
                        oli.Job_lkup__c=pslines.Job__c;
                        oli.Quantity = pslines.Job_Invoice_Duration__c; 
                        oli.UnitPrice=0;
                     }
						if( (oli.Quantity!=NULL) && (oli.PriceBookEntryId!=NULL))
                        {	olilist1.add(oli);
                             psupdlist.add(pslines);
                         
                        }
             }}
           if(psupdlist.size()>0)
                {
                      newopp.OwnerId=vLstUserop.Id;
                      newopp.stagename='To be reviewed';
                      Nxtoptycreationdate=rcard[0].Next_Opportunity_Creation_Date__c;
                      Closedate=rcard[0].Next_Billable_Date__c;
                      BillableCycle=rcard[0].Opportunity_Creation_Frequency__c;
                      InvoiceSentby=rcard[0].Invoice_sent_by__c;
                      InvoiceSentTo=rcard[0].Invoice_sent_to__c;
                      Accntterms=rcard[0].Account_Terms__c;
                      RateCardtype=rcard[0].Rate_Card_Type__c;
                 }
                      
                 if(ps[0].Who_to_Invoice__c=='Medicare Account')   
                {
                    newopp.Medicare__c = true;
                    newopp.AccountId=medaccId ;
					//Check record type and assign respective name to oppty
                    if(ps[0].RecordType.name =='Podiatry')
                        newopp.Name= MedaccName +'-' + RecNamePodwP + '-'+ Nxtoptycreationdate.format();
               else if(ps[0].RecordType.name =='Audiology')
                        newopp.Name= MedaccName +'-' + RecNameAudwP + '-'+ Nxtoptycreationdate.format();
               else if(ps[0].RecordType.name =='Dietetics')
                        newopp.Name= MedaccName +'-' + RecNameDiteticscwP + '-'+ Nxtoptycreationdate.format();
                if(ps[0].RecordType.name =='Diversional Therapy')
                        newopp.Name= MedaccName +'-' + RecNameDivTrpwP + '-'+ Nxtoptycreationdate.format();
              }
                  
               if(ps[0].Who_to_Invoice__c=='DVA Account')
              {
                    newopp.DVA__c = true;
                    newopp.AccountId=DVAaccId ;
                if(ps[0].RecordType.name =='Podiatry')
                        newopp.Name= DVAaccName  +'-' + RecNamePodwP + '-'+ Nxtoptycreationdate.format();
               else if(ps[0].RecordType.name =='Audiology')
                        newopp.Name= DVAaccName  +'-' + RecNameAudwP + '-'+ Nxtoptycreationdate.format();
               else if(ps[0].RecordType.name =='Dietetics')
                        newopp.Name= DVAaccName  +'-' + RecNameDiteticscwP + '-'+ Nxtoptycreationdate.format();
                if(ps[0].RecordType.name =='Diversional Therapy')
                        newopp.Name= DVAaccName  +'-' + RecNameDivTrpwP + '-'+ Nxtoptycreationdate.format();
              }
                  
                 newopp.closedate=Closedate;
                  newopp.Billable_Cycle__c=BillableCycle;
                  
                  //check Patient service Record type and assign respective record type id to oppty
                    if(ps[0].RecordType.name =='Podiatry')
                        newopp.RecordTypeId=RtIdPodwP ;
               else if(ps[0].RecordType.name =='Audiology')
                        newopp.RecordTypeId=RtIdAudwP ;
               else if(ps[0].RecordType.name =='Dietetics')
                        newopp.RecordTypeId=RtIdDiteticscwP ;
               else if(ps[0].RecordType.name =='Diversional Therapy')
                        newopp.RecordTypeId=RtIdDivTrpwP ;
               
                    /////////////////////
                  
                 newopp.RateCard__c=rcard[0].Id;
                  newopp.Invoice_sent_by__c=InvoiceSentby;
                  newopp.Invoice_sent_to__c=InvoiceSentTo;
                  newopp.Date_From__c=ps[0].Job_Start_Datew_otime__c;
                  newopp.Patient_DVA_No__c = ps[0].Patient_DVA_Number__c;
                  newopp.Patient_Medicare_No__c = ps[0].Patient_Medicare_No__c;
                  newopp.AHP_Type__c= ps[0].Podiatry_Services__c;
                  newopp.Date_To__c=Nxtoptycreationdate;
                  newopp.Service_Type__c=RateCardtype;
                  oplist.add(newopp);
                  psupdlist.clear();
                              
    }
	if(olilist1.size()>0 && oplist.size()>0)
    {
        insert oplist;
        insert olilist1;          
return (medaccId );
}}
And below in test class,as per my knowledge i've created test class and try to cover few apex code line, but it not showing me any test code coverage,
as I am creating test class in correct way or wrong way ? Please guide
Please explain solution and how to write test class for this in brief
 
@Istest(SeeAllData=True)
public class TestCreateOpty3 {
    Static testmethod void CreateOptyTest1()
    {
        Integer extid;
        User vLstUserop = [select id from User where Opportunity_Owner__c=true and IsActive=true LIMIT 1];
          date myDate = date.today();
        Map<String, Schema.SObjectType> sObjectMap = Schema.getGlobalDescribe() ;
            Map<String,Schema.RecordTypeInfo> recordType = sObjectMap.get('Opportunity').getDescribe().getRecordTypeInfosByName();
            ID RtIdPodwP,RtIdAudwP,RtIdDiteticscwP,RtIdDivTrpwP,RtIdMntHlthwP,RtIdOccTrpwP,RtIdOptmwP,RtIdPhytrpwP,RtIdPhyTrpExClswP,RtIdRegNrsewP,RtIdSpchTrpwP;
            String RecNamePodwP,RecNameAudwP,RecNameDiteticscwP,RecNameDivTrpwP,RecNameMntHlthwP,RecNameOccTrpwP,RecNameOptmwP,RecNamePhytrpwP,RecNamePhyTrpExClswP,RecNameRegNrsewP,RecNameSpchTrpwP;       
        RtIdPodwP = recordType.get('Podiatry with Patients').getRecordTypeId();
        RecNamePodwP=recordType.get('Podiatry with Patients').getName();
        RtIdAudwP = recordType.get('Audiology with Patients').getRecordTypeId();
        RecNameAudwP=recordType.get('Audiology with Patients').getName();
        Id MedicareAccRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Medicare Account').getRecordTypeId();                
        
        List<Account> Parentacc= new List<Account>();
        
       Parentacc.add(new Account(RecordTypeId = MedicareAccRecordTypeId, 
                                          Name = 'Department of Human Services',
                                          Account_Address__c = '123 street 123', 
                                          ABN__c = '1236523652',
                                          Email__c = 'test1@test.com', 
                                          Facility_Notification_Opt_Out__c = True,
                                          Is_Admin__c = True,
                                          Active__c = True));
      insert Parentacc;
        
         List<Contact> Con= new List<Contact>();
        Con.add(new contact(FirstName = '',
                              LastName = 'TestContact',
                              accountId = Parentacc[0].id,
                              MobilePhone = '1234567890',
                              email = 'test@skedulo.com',
                              MailingStreet = 'ABC',
                              Active__c = True,
                              MailingCity = 'ABC',
                              MailingState = 'ABC',
                              MailingPostalCode = 'ABC',
                              MailingCountry = 'ABC'));
            insert Con;
            
          Parentacc[0].Account_Contact__c = con[0].id;
          update Parentacc;
        
         List<Account>  acc= new List<Account>();
         acc.add(new Account(RecordTypeId = MedicareAccRecordTypeId,         
                                    Name = 'Medicare Account',
                                    ParentId=Parentacc[0].Id,
                                    Account_Address__c = '123 street 123',
                                    ABN__c = '12345678912',
                                    Email__c = 'test@test.com',
                                    Facility_Notification_Opt_Out__c = True,
                                    Medicare_Number__c = '123456789',
                                    Is_Admin__c = True,
                                    Active__c = True,
                                    Card_Expiry_Date__c = system.today().addDays(10)));
           insert acc; 
        
         sked__Region__c Reg = new sked__Region__c(Name='SYD');
         Reg.sked__Timezone__c='Australia/Sydney';
         insert Reg;
        
         sked__Location__c Loc = new sked__Location__c( Name = 'Test Location',sked__Region__c = Reg.Id,sked__Address__c = 'Test Address' );
         insert Loc;
        
         sked__Resource__c Res = new sked__Resource__c(Name = 'Test Resource', sked__User__c=UserInfo.getUserId(),sked__Primary_Region__c = Reg.Id);
         insert Res;
        
         Patient__c pat1 = new Patient__c(First_Name__c='First', Last_Name__c='Last',Medicare_Account__c=acc[0].id, Location__c=Loc.Id, Patient_Status__c='Active');
         Patient__c[] pat = new Patient__c[]{pat1};     
         insert pat;
        
        List<sked__Job__c> job=new List<sked__Job__c>();         
        job.add(new sked__Job__c(skdate__Finish__c = '20/08/2014 8:30 AM',
                                            skdate__Start__c = '18/08/2014 8:30 AM',
                                            Invoice_Start__c = DateTime.parse('18/08/2014 8:30 AM'),
                                            Invoice_Finish__c = DateTime.parse('20/08/2014 8:30 AM'),
                                            sked__Duration__c = 501,
                                            sked__Region__c = Reg.Id,
                                            sked__Type__c='Podiatry Clinic',
                                            Job_Billable__c =true,
                                            Resource_Name__c=Res.Name));
         
         job.add(new sked__Job__c(skdate__Finish__c = '20/08/2014 8:30 AM',
                                            skdate__Start__c = '18/08/2014 8:30 AM',
                                            Invoice_Start__c = DateTime.parse('18/08/2014 8:30 AM'),
                                            Invoice_Finish__c = DateTime.parse('20/08/2014 8:30 AM'),
                                            sked__Duration__c = 501,
                                            sked__Region__c = Reg.Id,
                                            sked__Type__c='Audiology Clinic',
                                            Job_Billable__c =true,
                                            Resource_Name__c=Res.Name));
            
         insert job;
        
         List<Patient_Services__c> ps= new List<Patient_Services__c>();
         ps.add(new Patient_Services__c(Service_Type__c = 'Podiatry',
                                                Patient__c = pat1.Id,
                                                Job__c = job[0].id,
                                                Who_to_Invoice__c='Medicare Account',
                                                RecordTypeid= '01290000000hN0p',
                                                Patient_Service_Invoice_Start__c=DateTime.parse('18/08/2014 8:30 AM'),
                                                Patient_Service_Invoice_Finish__c=DateTime.parse('20/08/2014 8:30 AM'),
                                                Patient_Service_Lunch__c='10'));
         ps.add(new Patient_Services__c(Service_Type__c = 'Audiology',
                                                Patient__c = pat1.Id,
                                                Job__c = job[1].id,
                                                Who_to_Invoice__c='Medicare Account',
                                                RecordTypeid= '012O000000011Im',
                                                Patient_Service_Invoice_Start__c=DateTime.parse('18/08/2014 8:30 AM'),
                                                Patient_Service_Invoice_Finish__c=DateTime.parse('20/08/2014 8:30 AM'),
                                                Patient_Service_Lunch__c='10'));
                
        insert ps;
        
         List<PricebookEntry > Pricebook=new List<PricebookEntry >();
        Pricebook =[select id from PricebookEntry where IsActive=true limit 1];
         List<Rate_Card__c> rcard=new List<Rate_Card__c>();    
        rcard.add(new Rate_Card__c(Is_Active__c=true,
                                    Rate_Card_Type__c='Podiatry',
                                    Job_Type__c='Podiatry Clinic',
                                    Invoice_sent_by__c='Email',
                                    Invoice_sent_to__c='Account',
                                    PricebookEntryId__c= Pricebook[0].id,
                                    Treatment_Rate__c=100.00,
                                    Account__c = acc[0].Id,
                                    Which_Rate_to_use_withpatients__c='Always use Treatment Rate',
                                    Next_Opportunity_Creation_Date__c=date.parse('18/08/2016')));
        
       
        rcard.add(new Rate_Card__c(Is_Active__c=true,
                                    Rate_Card_Type__c='Audiology',
                                    Job_Type__c='Audiology Clinic',
                                    Invoice_sent_by__c='Email',
                                    Invoice_sent_to__c='Account',
                                    PricebookEntryId__c= Pricebook[0].id,
                                    Treatment_Rate__c=100.00,
                                    Account__c = acc[0].Id,
                                    Which_Rate_to_use_withpatients__c='Always use Treatment Rate',
                                    Next_Opportunity_Creation_Date__c=date.parse('18/08/2016')));
         insert rcard;
        
         List<Opportunity> opty=[select Id,Opty_No__c from Opportunity order by CreatedDate DESC limit 1];
         extid=Integer.valueOf(opty[0].Opty_No__c)+1;
       
        List<Opportunity> newopp=new List<Opportunity>();
         newopp.add(new Opportunity(
         			Optycreationbatch__c='Medicare-WP-'+myDate+'-'+extid,
                     OwnerId=vLstUserop.Id,
                     stagename='To be reviewed',
                     Medicare__c = true,
                     AccountId=acc[0].Id ,
                     Name=  acc[0].Name +'-' + 'Podiatry with Patients' + '-'+ myDate.format(),
                     Invoice_sent_by__c=rcard[0].Invoice_sent_by__c,
                     Invoice_sent_to__c=rcard[0].Invoice_sent_to__c,
                     closedate=myDate,
                     AHP_Type__c= ps[0].Podiatry_Services__c,
                     Date_To__c=rcard[0].Next_Opportunity_Creation_Date__c,
                     Service_Type__c= rcard[0].Rate_Card_Type__c,
                     RecordTypeId=RtIdPodwP,
                     RateCard__c=rcard[0].Id));
        
        newopp.add(new Opportunity(
            						Optycreationbatch__c='Medicare-WP-'+myDate+'-'+extid+1,
                                     OwnerId=vLstUserop.Id,
                                     stagename='To be reviewed',
                                     Medicare__c = true,
                                     AccountId=acc[0].Id ,
                                     Name=  acc[0].Name +'-' + 'Audiology with Patients' + '-'+ myDate.format(),
                                     Invoice_sent_by__c=rcard[0].Invoice_sent_by__c,
                                     Invoice_sent_to__c=rcard[0].Invoice_sent_to__c,
                                     closedate=myDate,
                                     AHP_Type__c= ps[1].Podiatry_Services__c,
                                     Date_To__c=rcard[0].Next_Opportunity_Creation_Date__c,
                                     Service_Type__c= rcard[0].Rate_Card_Type__c,
                                     RecordTypeId=RtIdAudwP,
                                     RateCard__c=rcard[0].Id));
        insert newopp;
                
        List<OpportunityLineItem> oli = new List<OpportunityLineItem>();
          oli.add(new OpportunityLineItem(
                                         OpportunityId =newopp[0].id,
                                         PriceBookEntryId = rcard[0].PricebookEntryId__c,
                                         Provider_Name__c=ps[0].Resource_Name__c,  
                                         Patient_Service__c=ps[0].Id,
                                         Rate_Card__c=rcard[0].Id,
                                         Patient_Service_Invoice_Start__c=ps[0].Patient_Service_Invoice_Start__c,
                                         Patient_Service_Invoice_Finish__c=ps[0].Patient_Service_Invoice_Finish__c,
                                         Patient_Service_Lunch__c=ps[0].Patient_Service_Lunch__c,
                                         UnitPrice = rcard[0].Treatment_Rate__c,
                                         Invoice_Start__c=ps[0].Job_Invoice_Start__c,
                                         Invoice_Finish__c=ps[0].Job_Invoice_Finish__c,
                                         Lunch_Break_Duration_from_Job__c=ps[0].Lunch_Break_Duration_from_Job__c,
                                         AHP_Type__c=ps[0].Podiatry_Services__c,
                                         Quantity = 1,
                                         Job_lkup__c=ps[0].Job__c)
                                         );
       oli.add(new OpportunityLineItem(
                 OpportunityId =newopp[1].id,
                 PriceBookEntryId = rcard[1].PricebookEntryId__c,
                Provider_Name__c=ps[1].Resource_Name__c,  
                 Patient_Service__c=ps[1].Id,
                 Rate_Card__c=rcard[1].Id,
                 Patient_Service_Invoice_Start__c=ps[1].Patient_Service_Invoice_Start__c,
                 Patient_Service_Invoice_Finish__c=ps[1].Patient_Service_Invoice_Finish__c,
                 Patient_Service_Lunch__c=ps[1].Patient_Service_Lunch__c,
                 UnitPrice = rcard[1].Treatment_Rate__c,
                 Invoice_Start__c=ps[1].Job_Invoice_Start__c,
                 Invoice_Finish__c=ps[1].Job_Invoice_Finish__c,
       			 Lunch_Break_Duration_from_Job__c=ps[1].Lunch_Break_Duration_from_Job__c,
       			 AHP_Type__c=ps[1].Podiatry_Services__c,
                 Quantity = 1,
                 Job_lkup__c=ps[1].Job__c));
          insert oli;
        }}


 
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