• StephenKenny
  • NEWBIE
  • 485 Points
  • Member since 2010
  • Technical Architect, Cloud Enthusiast, Innovator
  • The Whiteshed Company


  • Chatter
    Feed
  • 16
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 91
    Replies
<apex:variable value="{!user1 !=''}"  var="op1"/>
<apex:outputText value="{!op1}"/>   //o/p True
<apex:variable value="{!user2 !=''}" var="op2"/>
<apex:outputText value="{!op2}"/>   //o/p False
 
<apex:selectList value="{!rSelected}" >
    <apex:selectOption itemValue="Select"/> 
    <apex:selectOption itemLabel="One" itemValue="One" rendered="{!op1}" />	
    <apex:selectOption itemLabel="Two" itemValue="One" rendered="{!op2}"/>
</apex:selectList>

Logically, for options, One should be displayed and Two should not be displayed, but both of them are not displayed.
  • March 16, 2015
  • Like
  • 0
I have a Take Case button on cases, when clicked is to change the case owner, status and substatus accordingly, fill in some dates, mark all this in case history as well as mark that the button was clicked.

We're finding that when the button is clicked the first time, everything works great, I can see in history that the button was clicked.  But if the button is clicked a second time, it doesn't show that.  It only shows that it updated the user.

How can I get it to fill in EVERYTIME its clicked?
 
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");

caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.Status = 'In Progress';
caseObj.Take_Case_button_clicked__c = "Take Case";
var roleName = '{!$UserRole.Name}';
if((roleName.indexOf("Tier 3") != -1) || (roleName.indexOf("CW NPI") != -1) || (roleName.indexOf("CW CPI") != -1) || (roleName.indexOf("Field Operation") != -1) || (roleName.indexOf("Service Engineer") != -1))
{
caseObj.Substatus__c = 'Open with Product Specialists';
if('{!Case.CW_T3_First_Reponse__c}'=='')
{
caseObj.CW_T3_First_Reponse__c=new Date().toJSON();
}
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
if('{!Case.CW_Advance_Support_Needed__c}' == false)
{
caseObj.CW_Advance_Support_Needed__c = true;
}
}
else
{
caseObj.Substatus__c = 'Open with Support Advocates';
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
}
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
window.parent.location.href="/{!Case.Id}";
}

 
  • February 25, 2015
  • Like
  • 0
I am trying to cut down my coding to allow for more space: Can someone please help me combine this onto one line to save characters?
Do you use OR or CONTAINS??? Many thanks
IF(BEGINS (MailingPostalCode, "BT7 "), "South", 
IF(BEGINS (MailingPostalCode, "BT8 "), "South", 
IF(BEGINS (MailingPostalCode, "BT9 "), "South", 
IF(BEGINS (MailingPostalCode, "BT10"), "South", 




 

Hi All,

I am creating Report on Contacts with Job Applications.

If the a particular person have applied for multiple Job, I want only record of that contact.

Currently, i get four records for that contact,since he applied for 4 Jobs. But I need only one record for that person. 

How can I do this ??

Regards,

Raghu

Hello,

I have created a custom object called Reservaitons. I am looking for a way to update a field as soon as I receive a second reservation(2nd line item).

I tried a workflow rule but on the criteria I couldn't find anything that is about a second line item. My unique field is ReservationID but the client might already have a reservation on his card. 
Hi all, 

our org recently decided to move all the users to full licenses from platform. However, during the discussion, we notices, all our platform licenses are now converted to full licenses. So when I try to create a new user with platform, the licenses type does not show up as an option, only full licneses. The problem is, we did not create/transfer the profile to full licenses. Now that I have some user pending, what is the best/easy/fast way to create or move those profiles to full liceneses. 

Is there a way I can move instead of creating those profiles from scratch with full licenes? 
I'm new to APEX and I would be grateful if someone could help me with below trigger.
when there is new attachment added to custom Project_Edition__c object I need Venue_Contract_Attached__c to be ticked automatically (and unticked when attachment is deleted)
 
trigger CountAttachments on Project_Edition__c (before insert, before delete)
{
if(trigger.isinsert){
List<Project_Edition__c> co = [select id from Project_Edition__c where id =: Trigger.New[0].ParentId];
If(co.size()>0)         
{             
co[0].Venue_Contract_Attached__c = True;             
update co;         
}
}


if(trigger.isdelete){

List<Project_Edition__c> co = [select id from Project_Edition__c where id =: Trigger.old[0].ParentId];         
If(co.size()>0)         
{             
co[0].Venue_Contract_Attached__c = false;             
update co;         
}
}
}

I'm getting all sorts of errors, last one being "Error: Compile Error: Invalid field ParentId for SObject Project_Edition__c at line 4 column 93"

 
  • February 17, 2015
  • Like
  • 0
Hi,
I have a multiselect picklist which is displayed on a VF page using <apex:inputfield>
It worked well until I added&edited the field values. 
The options in the VF page's multiselect field stay the same(no new options added to the picklist)

How can I fix this?
I am trying to use schema object to retrieve record type using the ID. I am able to retrieve the object name say account using the below query, but how do i retrieve record type of the object using this information without SOQL

String objName = objId.getSObjectType().getDescribe().getName();  // Objid is the id of the record
The following query returns createdbyid/LastModifiedbyId instead of name in apex whereas returns name when using workbench or query editor in dev console. How do i get the name directly instead of ID?  

select Customer_Number__c,Name,Quality_Rating__c,Primary_Institution_Type__c,CreatedBy.Name,CreatedDate,LastModifiedBy.Name,LastModifiedDate from Account WHERE ID =: myID 
Ok, so we have an External Id field that's sets to unique case-insensitive, yet we have about 200 records with the same value. And it's either blank or null values repeated between records.  What gives? Is this expected behavior? My searches have turned up nothing on this.  Is this really, unique except...?
Hi everyone,
Hoping someone can help shed some light - I'm getting different record counts from the Apex DataLoader than from the Explorer SOQL tester or our API calls.
We're trying to replicate data down from a Salesforce instance using the partner API.
The application we've built logs in under the API account we've set up, then issues a Query request against the Salesforce instance. Here's the query we're sending:

SELECT Id, Subject, AccountId, OwnerId, Type, CreatedDate, RecurrenceActivityId, RecurrenceStartDateTime, RecurrenceType, Call_Result__c, Case_Safe_ID__c, Event_Status__c, Task_Sub_Type__c, Task_Type__c FROM Event

This call returns 2 records sucessfully, and the QueryResult's done property is true.
I copy the same query and run it in the Apex Explorer SOQL tool, which returns the same 2 records.
I open the Apex DataLoader, log in with the same account, choose export, then use the same SOQL query to define the export. The DataLoader exports 8 records instead of 2.
I've checked to see whether the 6 extra records are deleted, archived, private, or in some different status than the two that are returned, but they're not. If I copy the IDs for the extra records, I can browse to them in Salesforce, so they seem to be real records. I've tried QueryAll in Explorer, but it still only returns 2 records.

1. Does anyone have any ideas on why there would be differences based on which tool I'm using? I was under the impression that everything should be the same as long as I'm using the same login credentials.
2. Does anyone have any recommendations on what changes I might need to make to the Query() call in order to get all 8 records?
 
I have created a trigger on the Opportunity Object.  When I test it under the GUI, the field gets populated properly.  Now I need to get the Test Class to run the trigger so that I can move it to Prod.

Here is the trigger:

trigger Referral_Name_autofill on Opportunity (before insert) {

    For (Opportunity n : Trigger.new)    { 
    
        IF (n.referrer_SFID__c != Null) {
        
            String found = '';        
            System.Debug('New SFID In; ' + n.referrer_SFID__c);
            System.Debug('New AccountID In; ' + n.AccountID);
            Contact[] HofH = [SELECT Id, Relationship__c, Name FROM Contact WHERE AccountID = :n.referrer_SFID__c];
        
            FOR(Contact h:HofH){
            
                IF (h.Relationship__c == 'Head of HH') {
                    
                    IF (found == '')    {
                        n.Referral_Name__c = h.Id;
                        found = 'FOUND';
                    }
                
                }
            
            }
            
            IF (found == '')    {
            
                Contact[] contacts = [SELECT Id, TDAI_WM__Relationship__c, Name FROM Contact 
                                        WHERE AccountID = :n.referrer_SFID__c
                                        ORDER BY CreatedDate DESC];
                                        
                FOR(Contact c:contacts){
                    
                    n.Referral_Name__c = c.Id;
                       BREAK;
                
                }
            
            }            
        
        }
    
    }

}

Here is the test class:

@isTest
private class Referral_Name_autofill_Testclass {
static testMethod void myUnitTest() {
System.debug('Here');
  Opportunity op1 = New Opportunity( AccountId='001e000000SobCeAAJ', Name='TestOpp', referrer_SFID__c='001e000000SobCe',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op1;
        System.debug('Referral Name after trigger fired: ' + op1.Referral_Name__c);
    
    Opportunity op2 = New Opportunity( AccountId='001e000000SZhdgAAD', Name='TestOpp', referrer_SFID__c='001e000000SZhdg',
                                   StageName='Prospect Received', CloseDate=Date.today());
        // Insert Opportunity
        insert op2;
        System.debug('Referral Name after trigger fired: ' + op2.Referral_Name__c);
    
       
    FOR(Contact n:[SELECT Id, AccountId FROM Contact LIMIT 1]){
        System.debug('Here we go');
        Opportunity op = New Opportunity( AccountId=n.AccountId, Name='TestOpp', referrer_SFID__c=n.Id,
                                   StageName='Prospect Received', CloseDate=Date.today() );
        // Insert Opportunity
        insert op;
        
        // Retrive Referal Name
        op = [SELECT Referral_Name__c FROM Opportunity WHERE Id =:op.Id];
        System.debug('Referral Name after trigger fired: ' + op.Referral_Name__c);
    }
}
}

According to the Test Execution Log, none of the SOQL Queries pull any rows.  When I run them individually in DC, I get the correct record I need.  I know it is something that I am not seeing.
Hi all,


Is there a way to get the total of a custom field like total price?
I have a custom field for products called cost price. I have created a total cost price on oop products with a formula ( Quantity* Cost Price)

What I want is to create another field that sums up all the totals of total cost price and get a result of grand cost total.

Any ideas?

Thank you in advance
I wrote a trigger which is causing a side effect that email2case is not working. How do I debug this?

My code is
 
for (Case caseObj :Trigger.new) {
        if(caseObj.Origin == 'Email') {
            EmailMessage toEmail = [SELECT ToAddress FROM EmailMessage WHERE Incoming = true LIMIT 1];
            String te = String.valueOf(toEmail);
            System.debug('Email To Address is ' + toEmail);
            caseObj.Customer_Support_Email__c = te;
        }

    }

 
Hi All,

I am not expecting any code here but just a logic or at least a way to solve my problem.
My requirement is:
I have a batch job, in that I am invoking a class which is looking for a custom object records. The reords could be more than 30000. Now I want to go through each record, do some 'processing' based on values in other fields and then update a value field in the same record. Also during 'processing' step I might look for Account and other standard objects and their field values and use them in my calculation.
The problem in doing this is that I am loading too much data in memory and getting "Apex heap size too large" error.  I tried the suggestions given in some posts on how to update records using list, and load only required data in memory and believe me that I did all that but still getting error as I need to process huge number of records. Is there any other way to do this without getting memory error or without hitting the governor limits?
Hi, I have a number of checkbox fields that need to be completed and if they are missing i have created a text formula field to display missing data, however I have 1 field that is a date field and if this is blank needs to return that taht date field is missing;

Here is my formula without the date field and works perfectly

Data TypeFormula  
IF( Completeness_AML_Searches__c =100,"All Details Captured", 
"" 

&IF (Graydon_company_search_completed__c = False, "Graydon company search, ","")&"" 
&IF (World_Check_completed__c = False, "World check , ","")&"" 
&IF (Companies_House_checked__c = False, "Companies house , ","")&"" 
&IF (CreditSafe_checked__c = False, "Creditsafe , ","")&"" 
&IF (Land_registry_search_completed__c = False, "Land registry search, ","")&"" 
&IF (Net_worth_validated__c = False, "Net worth validated, ","")&"" 
&IF (Google_search_conducted__c = False, "Google search, ","")&"" 
&IF (Law_society_confirmed__c = False, "Law society confirmed, ",""))

However when I add the date field the syntax errors.. can someone help or suggest how i add an addtional line to check the date field...i cannot add as below;

&IF (Call_Credit_checked__c= False, "Call credit, ","")&"" 

IF(  Completeness_AML_Searches__c  =100,"All Details Captured", 
"" 

&IF (Graydon_company_search_completed__c = False, "Graydon company search, ","")&"" 
&IF (World_Check_completed__c = False, "World check , ","")&"" 
&IF (Companies_House_checked__c = False, "Companies house , ","")&"" 
&IF (CreditSafe_checked__c = False, "Creditsafe , ","")&"" 
&IF (Land_registry_search_completed__c = False, "Land registry search, ","")&"" 
&IF (Call_Credit_checked__c  = False, "call credit, ","")&"" 
&IF (Net_worth_validated__c = False, "Net worth validated, ","")&"" 
&IF (Google_search_conducted__c = False, "Google search, ","")&"" 
&IF (Law_society_confirmed__c = False, "Law society confirmed, ",""))

I get this error - Error: Incorrect parameter type for operator '='. Expected Date, received Boolean

I have System Administrator profile, still "Reset Security Token" is not visible for me. I have tried to receive the S.Token inmy mail box by resetting the password, still didnt receive any email. Can anyone suggest the workaround.
Hi,

I am really new to Salesforce and seeking your help to develop the bewlo idea. In my org, we are using Document to store the files. Document has a folder "Sales Tools". I want whenever users click on the "View" or "the document link" a custom message should pop- up and when user click Ok he should be able to see the document . Below is the screenshot to give more idea of what i am referring to.
User-added image

Please let me know how can i create a custom popu- message whenever i click on "View" or "Document Link"

Thanks a lot.
 
Hello,

I've got a trigger that is set to write geocode to a location field on the accounts page when an address is updated.

The trigger code is:
 
// Trigger runs getLocation() on Accounts with no Geolocation

trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new)
if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}

This works great - but what I am running into is the trigger will not fire if the Location__Latitude__s isn't null - that is to say if it already has geocode in it from a previous address, it won't put new geocode in because the field isn't empty.

How can I set this trigger to clear the field whenever the address is updated?

 
<apex:variable value="{!user1 !=''}"  var="op1"/>
<apex:outputText value="{!op1}"/>   //o/p True
<apex:variable value="{!user2 !=''}" var="op2"/>
<apex:outputText value="{!op2}"/>   //o/p False
 
<apex:selectList value="{!rSelected}" >
    <apex:selectOption itemValue="Select"/> 
    <apex:selectOption itemLabel="One" itemValue="One" rendered="{!op1}" />	
    <apex:selectOption itemLabel="Two" itemValue="One" rendered="{!op2}"/>
</apex:selectList>

Logically, for options, One should be displayed and Two should not be displayed, but both of them are not displayed.
  • March 16, 2015
  • Like
  • 0
Recently I've added trigger on contact populating Area_Code__c field based on the information added to contact.MailingCountry through CountryRegion__c custom setting. It works well:
trigger PopulateContactAreaCode on Contact (before insert, before update) {

    for(Contact contact : Trigger.new)
    {
        string AreaCode =  .getInstance(contact.MailingCountry).Area_Code__c;
        contact.Area_Code__c = AreaCode;
    }
}

but when I'm trying to replicate the code on lead:
trigger PopulateLeadAreaCode on Lead (before insert, before update) {

    for (Lead newLead : Trigger.new)
    {
        string AreaCode = CountryRegion__c.getInstance(Lead.Country). Area_Code__c;
        lead.Area_Code__c = AreaCode;
    }
}

it does gives me an error: "Error: Compile Error: Variable does not exist: CountryRegion__c at line 5 column 27"

CountThat CountryRegion__c custom setting is the same I've used for contacts, so not sure why the system acan't see it this time? Do I need a new separate custom setting for leads?

Thank you in advance!
  • February 25, 2015
  • Like
  • 0
I've added a couple Custom Fields to the Activities object and are specifically used for Tasks. What I would like the fields to do is draw in information from the associated Lead/Contact that is chosen for the Task, but I'm not sure how to handle this. I have little-to-no Apex coding experience but know that this is probably something that could be solved using Apex. Could someone either point me in the general direction of a solution to this problem or help me to figure one out myself?
I have a Take Case button on cases, when clicked is to change the case owner, status and substatus accordingly, fill in some dates, mark all this in case history as well as mark that the button was clicked.

We're finding that when the button is clicked the first time, everything works great, I can see in history that the button was clicked.  But if the button is clicked a second time, it doesn't show that.  It only shows that it updated the user.

How can I get it to fill in EVERYTIME its clicked?
 
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");

caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.Status = 'In Progress';
caseObj.Take_Case_button_clicked__c = "Take Case";
var roleName = '{!$UserRole.Name}';
if((roleName.indexOf("Tier 3") != -1) || (roleName.indexOf("CW NPI") != -1) || (roleName.indexOf("CW CPI") != -1) || (roleName.indexOf("Field Operation") != -1) || (roleName.indexOf("Service Engineer") != -1))
{
caseObj.Substatus__c = 'Open with Product Specialists';
if('{!Case.CW_T3_First_Reponse__c}'=='')
{
caseObj.CW_T3_First_Reponse__c=new Date().toJSON();
}
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
if('{!Case.CW_Advance_Support_Needed__c}' == false)
{
caseObj.CW_Advance_Support_Needed__c = true;
}
}
else
{
caseObj.Substatus__c = 'Open with Support Advocates';
if('{!Case.Incident_First_Response__c}'=='')
{
caseObj.Incident_First_Response__c=new Date().toJSON();
}
}
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
window.parent.location.href="/{!Case.Id}";
}

 
  • February 25, 2015
  • Like
  • 0
I am looking for trigger code on object "Child" that updates the field "Parent2.MyField".

Table       Fields
Child      Id, Parent1Id     <= Current 
Parent1  Id, Parent2Id
Parent2  Id, MyField

 
Hello,

I have created a custom object called Reservaitons. I am looking for a way to update a field as soon as I receive a second reservation(2nd line item).

I tried a workflow rule but on the criteria I couldn't find anything that is about a second line item. My unique field is ReservationID but the client might already have a reservation on his card. 
Hi everyone,
Hoping someone can help shed some light - I'm getting different record counts from the Apex DataLoader than from the Explorer SOQL tester or our API calls.
We're trying to replicate data down from a Salesforce instance using the partner API.
The application we've built logs in under the API account we've set up, then issues a Query request against the Salesforce instance. Here's the query we're sending:

SELECT Id, Subject, AccountId, OwnerId, Type, CreatedDate, RecurrenceActivityId, RecurrenceStartDateTime, RecurrenceType, Call_Result__c, Case_Safe_ID__c, Event_Status__c, Task_Sub_Type__c, Task_Type__c FROM Event

This call returns 2 records sucessfully, and the QueryResult's done property is true.
I copy the same query and run it in the Apex Explorer SOQL tool, which returns the same 2 records.
I open the Apex DataLoader, log in with the same account, choose export, then use the same SOQL query to define the export. The DataLoader exports 8 records instead of 2.
I've checked to see whether the 6 extra records are deleted, archived, private, or in some different status than the two that are returned, but they're not. If I copy the IDs for the extra records, I can browse to them in Salesforce, so they seem to be real records. I've tried QueryAll in Explorer, but it still only returns 2 records.

1. Does anyone have any ideas on why there would be differences based on which tool I'm using? I was under the impression that everything should be the same as long as I'm using the same login credentials.
2. Does anyone have any recommendations on what changes I might need to make to the Query() call in order to get all 8 records?