• jwhartfield
  • NEWBIE
  • 35 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 18
    Replies

Hello - I am writing a simple trigger to copy an auto-formula field text into the standard field of my custome object.  I have this error of...

Compile Error: Illegal assignment from LIST<Equipment__c> to LIST<Name> at line 2 column 9

 

My code is:

trigger AutoEName on Equipment__c (before insert, after update) {   
        List<name> NametoUpdate =
        [SELECT e.name
         FROM Equipment__c e
          For Update];
            
        For (Name n: NametoUpdate) {
             n == equipment__c.Auto_Name__c;               }
               
           update NametoUpdate;     
    }

 

Any help would be great.  Thanks!

When I first set up a site, I am always given the option to have the the type of new site be 'Guest' or 'Guest User License'.  I have not been able to find any documentation on what the difference is.  Does anyone know? 

Site Type Screenshot

 

I am using the mobile SDK for Android and want to use our new login page hosted on cloudforce.com (using the new Trialforce branding).  It looks like I need to do something to somehow override the 'getLoginUrl' method of theLoginActivity.java class.  I am using the Hybrid application template that Salesforce supplies in their SDK.

 

I'm not really an Android developer so I'm not sure how to do this.  I built the following class in the same folder that the VFConnectorApp.java class resides in (because that seems to do a similar override), but that didn't seem to change anything. How can I get my application to start using this new class?

public class LoginActivity extends com.salesforce.androidsdk.ui.LoginActivity {
/**
* Override this method to customize the login url.
* @return login url
*/
@Override
protected String getLoginUrl() {
return "https://sitename.cloudforce.com";
}
}

 

In my ORG, certain profiles have access to certain Visualforce pages.  I would like to conditionally render links only to pages that the logged in user has access to.  Is there any way to determine through Visualforce or Apex if a the current user has access to a specific Visualforce page?

I just installed a managed package (EasyPage) into our ORG.  After installing, anytime I make a new class or page the 'EasyPage' managed package is included in the list of dependencies found under in the 'Version Settings' tab of these new classes or pages.  These classes/pages are completely blank, so there are no actual dependencies on anything.  I tried to use Eclipse to tweak the XML and remove the dependency, but the VersionSettings keeps on coming back when I save.

 

Does anybody know why this might be happening?  Is this behavior by design?

I am trying to display to the user the attachments that are associated with an EmailTemplate object that they pick from a list.  According to the documentation, EmailTemplate attachments are stored in the Documents table and paired with their template by using the DocumentAttachmentMap.  But when I query the DocumentAttachmentMap, it is completely empty.  I have some EmailTemplates that I built with Attachments, so I expected to see some records in there.

 

Does anyone know where to find these Attachments or some caveat to displaying the records in the DocumentAttachmentMap table?

When I first set up a site, I am always given the option to have the the type of new site be 'Guest' or 'Guest User License'.  I have not been able to find any documentation on what the difference is.  Does anyone know? 

Site Type Screenshot

 

i'm not new to this board but had to create a new log in due to a new role with a different company.  Please excuse my newness LOL. 

 

I have the following piece of code and for the life of me can't figure out why count () will work but sum(fieldname) won't.  I haven't written code in some time so a refresher would be helpful.  I'm trying to sum all the child records sph value and place this value on the parent obejct in a field called sph.  what am I missing.

trigger Add_Sales_Actuals on Sales_Actuals__c(after insert, after update) {
 
    //Student_Call_Log are the related records
    //Student is the "main" record
    //Idea is to update a field on the main record whenever an edit is made to a related record   
    
    Sales_Actuals__c [] sa = Trigger.new;    
    String bapid = null;
    
    bapid = sa[0].BA_Position__c;        
    if(sa[0].Reporting_date__c != null  )  
        {               
            integer i = [select sum(sph__c) from Sales_Actuals__c where BA_Position__c = :bapid 
                                                                  ];           
            // update the master record  
          
           BA_Position__c [] baps =[select id, SPH__c     
                                          from BA_Position__c where id = :bapid];
                          
                            
               baps[0].SPH__c = i;               
             
             // write to database    
                 
             update baps[0];      
             i = 0;     
           }
 }

 

My test method fails due to a null pointer exception but this does no hapen in the UI runtime.

 

I get this both on the Save Method and Save Override.  If I can fix the Save then I'm sure I can apply it to the override.

 

This is a custom Lookup with a New/Add function.

 

The Test Method  -  the error is noted in a comment above the line.  I also had trouble with the runsearch at the end.

 

Any ideas?  Thanks.

 

/**
* Purpose : This class contains unit tests for the Trip Report controller extension.
*/
@isTest(seeAllData=true)
private class Test_CustomCampaignLkpCtrl{

private static ApexPages.StandardController ctl;
private static CustomCampaignLookupController ext;
private static ApexPages.StandardController ctlWithRecord;
private static CustomCampaignLookupController extWithRecord;

private static User mockAdminUser;

private static Campaign r;


static{

TripRptTestDataUtilityLib.getActiveAdminUserId();

//Build mock data
// setup With Item();

//Instantiate and empty controller.
ctl = new ApexPages.StandardController(new Campaign());

//Instantiate a full controller.
ctlWithRecord = new ApexPages.StandardController(r);
extWithRecord = new CustomCampaignLookupController(ctlWithRecord);
extWithrecord.isNew = true;


ext = new CustomCampaignLookupController(ctlWithRecord);


system.debug('**********************************');
system.debug('ctlWithRecord: ' + ctlWithRecord);
system.debug('extWithRecord: ' + extWithRecord);
system.debug('**********************************');


} // End

public Campaign campaign {get;set;} // new campaign to create
public List<Campaign> results{get;set;} // search results
public string searchString{get;set;} // search keyword

static testMethod void CanTestSaveOverride(){
String saveUrl = ext.SaveCampaign().getUrl();

}

static testMethod void CanTestSave(){
// Campaign c = new Campaign();
//Run the save() and verify:
//1: modified Report and Items
//2: Redirect URL matches the detail page for new report.
// Populate record.
Campaign extRecord = new Campaign();
extRecord = [select id, name from Campaign LIMIT 1];

extRecord.Name = 'Test Method Name';
extRecord.Description = 'Test Meth Desc';
//ERROR System.NullPointerException: Attempt to de-reference a null object Class.Test_CustomCampaignLkpCtrl.CanTestSave: line 67, column 1
extWithRecord.SaveCampaign();

//Verify the Url after the save() method occurred. chg from .Save()
String saveUrl = ext.SaveCampaign().getUrl();
system.debug( 'Save URL: ' + saveUrl );
// system.debug( 'Detail URL: ' + extWithRecord.controller.view().getURL() );

//ERROR not visible ext.runSearch();

}
} // End Class

 

The Controller:

 

/**
* Purpose : This class contains unit tests for the Custom Lookup.
*/
@isTest(seeAllData=true)
private class Test_CustomCampaignLkpCtrl{

private static ApexPages.StandardController ctl;
private static CustomCampaignLookupController ext;
private static ApexPages.StandardController ctlWithRecord;
private static CustomCampaignLookupController extWithRecord;

private static User mockAdminUser;

private static Campaign r;


static{

TripRptTestDataUtilityLib.getActiveAdminUserId();

//Build mock data
// setup With Item();

//Instantiate and empty controller.
ctl = new ApexPages.StandardController(new Campaign());

//Instantiate a full controller.
ctlWithRecord = new ApexPages.StandardController(r);
extWithRecord = new CustomCampaignLookupController(ctlWithRecord);
extWithrecord.isNew = true;


ext = new CustomCampaignLookupController(ctlWithRecord);


system.debug('**********************************');
system.debug('ctlWithRecord: ' + ctlWithRecord);
system.debug('extWithRecord: ' + extWithRecord);
system.debug('**********************************');


} // End

public Campaign campaign {get;set;} // new campaign to create
public List<Campaign> results{get;set;} // search results
public string searchString{get;set;} // search keyword

static testMethod void CanTestSaveOverride(){
String saveUrl = ext.SaveCampaign().getUrl();

}

static testMethod void CanTestSave(){
// Campaign c = new Campaign();
//Run the save() and verify:
//1: modified
//2: Redirect URL matches the detail page for new report.
// Populate record.
Campaign extRecord = new Campaign();
extRecord = [select id, name from Campaign LIMIT 1];

extRecord.Name = 'Test Method Name';
extRecord.Description = 'Test Meth Desc';
//ERROR System.NullPointerException: Attempt to de-reference a null object Class.Test_CustomCampaignLkpCtrl.CanTestSave: line 67, column 1
extWithRecord.SaveCampaign();

//Verify the Url after the save() method occurred. chg from .Save()
String saveUrl = ext.SaveCampaign().getUrl();
system.debug( 'Save URL: ' + saveUrl );
// system.debug( 'Detail URL: ' + extWithRecord.controller.view().getURL() );

//ERROR not visible ext.runSearch();

}
} // End Class

 

The Page:

 

<apex:page controller="CustomCampaignLookupController"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="campaign"
id="pg">

<apex:form >
<apex:pageMessages />
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

<!-- SEARCH TAB -->
<apex:tab label="Search" name="tab1" id="tabOne">

<apex:actionRegion >
<apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}" />
<span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
</apex:outputPanel>

<apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
<apex:pageBlock id="searchResults">
<apex:pageBlockTable value="{!results}" var="a" id="tblResults">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Active</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.isActive}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.isActive}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Type</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Type}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Type}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Description</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Description}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Description}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Expected Revenue</apex:outputPanel>
</apex:facet>
<apex:outputLink disabled="true" value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.ExpectedRevenue}','{!a.Id}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.ExpectedRevenue}</apex:outputLink>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>

</apex:tab>

<!-- NEW campaign TAB -->
<apex:tab label="New campaign" name="tab2" id="tabTwo" onclick="rerender">

<apex:pageBlock id="newcampaign" title="{!NewTitle}" >

<apex:pageBlockButtons location="top" >
<apex:commandButton action="{!savecampaign}" value="Save"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Campaign Information" columns="2">
<apex:inputField value="{!campaign.Name}" required="true" rendered="{!IsNew}"/>
<apex:outputField value="{!Campaign.Name}" rendered="{!NOT(IsNew)}"/>
<apex:inputField value="{!campaign.Status}"/>

<apex:inputField value="{!campaign.isActive}"/>

<apex:inputField value="{!campaign.Type}"/>
<apex:inputField value="{!campaign.Description}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="Planning" columns="2" >
<apex:inputField value="{!campaign.StartDate}"/>
<apex:inputField value="{!campaign.ExpectedRevenue}"/>
<apex:inputField value="{!campaign.EndDate}"/>
<apex:inputField value="{!campaign.BudgetedCost}"/>
<apex:inputField value="{!campaign.NumberSent}"/>
<apex:inputField value="{!campaign.ActualCost}"/>
<apex:inputField value="{!campaign.ExpectedResponse}"/>

</apex:pageBlockSection>

</apex:pageBlock>

</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables_considerations.htm


According to the above link a before delete trigger "can update an original object using an update DML operation nd the updates are saved before the object is deleted, so if the object is undeleted, the updates become visible". However, the contents of the trigger.old collection are read-only and trigger.new is only available in insert and update triggers. Therefore how can a objects value be modified as part of the trigger before delete?

 

I would like to be able to chage the value of one of the fields on an object when it is deleted.

 

 

Thanks

Bill

  • November 01, 2012
  • Like
  • 0

I have different levels

1.Apex:page

2.form

3.pageblock

3.pageblocksection

4.inputfield

 

Every level has their ids.Now in JScript I want to traverse through ids by document.getElementById....how to traverse ?Directly using .inputfield id is not working,,,,,Suggestion please!

Double N = math.random()*1000000000;
Long l = integer.valueof(N)*100;
string SNumber = string.valueof(l);

 

I have to insert that in a Text (External Id) fields.

 

Thanks 

 

 

The android sample application sometimes ask logs in automatically after the first login and sometimes ask for the username and password. Is it due to the slowness of the network.

thx

mahesh

Salesforce announced PermissionSet feature in its recent release, and I'm loving it. 

 

The Winter ‘12 Salesforce release has introduced Permission Sets as a new way to manage security within the application. Each user continues to have a Profile, but Permission Sets can now be given to individual users to extend their permissions beyond what is described in their Profile. One of the current limitations is that there is no way to manage assignments of Permission Sets for more than one user at a time, which makes administration tedious.

 

So I'm trying to build visualforce page for a System Administrator to manage (assign and remove) Permission Sets for more than one user at a time i.e., Develop a tool  to assign or remove one or more permission sets to or from one or more users.

 

However, I'm caught with error "Save error: DML not allowed on PermissionSetAssignment" when trying to make INSERT DML call on PermissionSetAssignment object. API version of my apex class is 23.0 and Docs too says that this object is Createable. 

 

What is that I'm missing or is it something not released yet?

Hi, 

I have a commandLink on click of which I want to ask the user for confirmation first i.e. whether he is sure to take the action. Once the user says Yes and the action is completed, I want a alert saying that the action was completed successfully. In order to achieve this, I used the onclick and oncomplete attributes of CommandLink. My issue is that if I use both the attributes, my commandLink action never gets fired. If I use only one of the them, everything works fine except I have only one of the popups. 


Is there an issue when both the onclick and oncomplete attribute are used together? Following is a sample code:

 

<apex:commandLink value="Test" action="{!myAction}" onclick="return window.confirm('Are you sure?');" oncomplete="alert('Event Completed');" />

 

 

Hi all,

 

I recently came across a problem where I had a Visualforce page displayed on a page layout and the height of it needed to be defined according to how many records were returned in the list I was displaying. After doing a little poking around, I came up with a cool solution I am happy to share. First step, the div that displays the Visualforce page is actually given the id of the Visualforce page itself - so you need to first find the id of the Visualforce page. Next, create an S-Control to do an onload resizing of this particular div element based on a query defined within the script itself. Below is an example of resizing a Visualforce page displayed on the account that displays a list of active contacts.

 

<script type="text/javascript" src="/js/functions.js"></script> 
<script src="/soap/ajax/12.0/connection.js"></script> 
<script type="text/javascript">
window.onload = resizeWindow(); 
function resizeWindow(){
	//Ensure a valid Salesforce connection.
	sforce.connection.sessionId = "{!API.Session_ID}"; 
	//Set account id of account used in contact query.
	var accountid = "{!Account.Id}";
	//Retrieve a list of contacts on the account that are not inactive.
	result = sforce.connection.query("Select Id from Contact where AccountId = '"+accountid+"' and Inactive__c != true"); 
	//Create a pixel variable to assign the dynamic height. This example adds an extra 50px to display the top part of the page in 	the case no records are retrieved.
	contactsize = result.getArray("records").length*30+50+'px';
	//Retrieve the height of the div the Visualforce page lies in and set it to the new dynamic size. The id is the actual id of 	the Visualforce page.
	top.document.getElementById("066P00000008bke").height = contactsize;
	}
</script>

 

Next, add this S-Control to the page layout with a height of 0px and this should resize your page onload. Enjoy!

 

In several projects, in several orgs, I've scheduled some Batch Apex jobs to run nightly to process large numbers of records. I've run into a couple of problems that are leaving me very uncertain about whether Batch Apex really can handle large jobs.

Every now and then, a job will fail with this error: Unable to write to any of the ACS stores in the alloted time. I first encountered this in September 2010. I filed a Case and created a discussion group posting (http://boards.developerforce.com/t5/Apex-Code-Development/Unable-to-write-to-any-of-the-ACS-stores-in-the-alloted-time/m-p/205908#M36022). After a few weeks, I was finally told that it was an internal issue that had been resolved. After months of running nightly Batch Apex jobs without this problem, it just recurred.

A second issue is that, every now and then, a Batch Apex job gets stuck in the queue in the "Queued" state. When you launch a Batch Apex job, it gets added to the queue in the "Queued" state, and when the system gets around to executing it, the job gets moved to a "Processing" state. Well, I have batch jobs that have been stuck in the "Queued" state since early January. I've had cases open on this problem for over a month, and while the Case finally found its way to Tier 3 Support, there's still no sign of a resolution.

In both cases, the issue is NOT an Apex coding problem. It's an issue with how the platform is queueing and processing Batch Apex jobs.

I'm wondeirng whether anybody else has run into these problems, or other problems executing Batch Apex jobs. What problems have you run into? How have you resolved or worked around them?

Thanks for your insights.

 
  • February 04, 2011
  • Like
  • 0

I am trying to display to the user the attachments that are associated with an EmailTemplate object that they pick from a list.  According to the documentation, EmailTemplate attachments are stored in the Documents table and paired with their template by using the DocumentAttachmentMap.  But when I query the DocumentAttachmentMap, it is completely empty.  I have some EmailTemplates that I built with Attachments, so I expected to see some records in there.

 

Does anyone know where to find these Attachments or some caveat to displaying the records in the DocumentAttachmentMap table?

Here's my situation: I've got approx. 200K Accounts/Customers in my SFDC instance, and now need to calculate and assign a LCV (Lifetime Customer Value) to each of these. I've got the individual metrics and the LCV function defined. The plan is apply computeLCV() "one-time" to every existing customer in order that I have this value for all Accounts. Then, on an on-going basis I would use a "after update" trigger to re-calc LCV if any of the metric-bearing field change. Straightforward!

 

But, I'm not sure what's the correct approach to the handle the "one-time 200K Account" calculateLCV processing!! Should I:

 

1> Use scheduled Apex:

global class calculateLCV implements Schedulable { 
 global void execute(SchedulableContext ctx) {
 // Query/retrieve and calculate LCV for all 200K existing Account}

I could then schedule this job to run just once! After a successful run, delete it!

 

2> Use the Bulk API to extract and process the 200K Accounts

 

3> Some other alternative e.g. regular Apex, invoked via a button click to do the same thing (and later removed), or Anonymously execute some Apex code to achieve the desired calculation, etc.

 

Thanks for your suggestions!

  • February 02, 2011
  • Like
  • 0

Hello - I am writing a simple trigger to copy an auto-formula field text into the standard field of my custome object.  I have this error of...

Compile Error: Illegal assignment from LIST<Equipment__c> to LIST<Name> at line 2 column 9

 

My code is:

trigger AutoEName on Equipment__c (before insert, after update) {   
        List<name> NametoUpdate =
        [SELECT e.name
         FROM Equipment__c e
          For Update];
            
        For (Name n: NametoUpdate) {
             n == equipment__c.Auto_Name__c;               }
               
           update NametoUpdate;     
    }

 

Any help would be great.  Thanks!

If you make a multi-select picklist dependent on a picklist then use them in a VF page the left/right arrows will vanish as soon as you perform an action method.

e.g. create a custom object called MSP. Now on object MSP__c create a required text field, a picklist (2 or 3 values) and a multi-select picklist (4 or 5 values).

 

Field Label       API Name             Data Type
First Name        First_Name__c        Text(25) - required to save record
Master Picklist   Master_Picklist__c   Picklist
Test MSP          Test_MSP__c          Picklist (Multi-Select)

 In the MSP tab create a record.

Create the following VF page and Class (extensions controller)

 

public class MSP_EXT {

    public MSP__c MSPrec {get; set;}
    
    public MSP_EXT(ApexPages.StandardController controller) {
        MSPrec = (MSP__c) controller.getRecord();
    }
    
    public PageReference mySave() {
        update MSPrec;
        return null;
    }
}

VF page testMSP

 

<apex:page id="page1" standardController="MSP__c" extensions="MSP_EXT" >
    <apex:form id="form1">
        <apex:pageBlock id="pb1">

            <apex:pageBlockButtons id="pbb1" location="both">
                <apex:commandButton id="btn1" value="Save" action="{!mySave}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection id="pbs1">

                <apex:inputField id="inp1" value="{!MSP__c.First_Name__c}"/>
                <apex:inputField id="inp2" value="{!MSP__c.Test_MSP__c}"/>
                <apex:inputField id="inp3" value="{!MSP__c.Master_Picklist__c}"/>

            </apex:pageBlockSection>

            <apex:pageMessages id="msgs1"/>

        </apex:pageBlock>

    </apex:form>
</apex:page>

So now try your apex page with the record you created:    yourInstance.salesforce.com/apex/testMSP?id=yourRecordId

 

 

Now save your record with and without a value in the required text field - no problems right? Everything works fine in the VF page and the Standard page.

 

Now with the Field Dependencies button make the multi-select picklist dependent on the picklist and make a few dependent values.

In the MSP Tab the Standard page works fine trying to edit the record with or without a value in the text field.

Go to the VF page again and whether there is a value in the text field or not, when you click the button the multi-select picklists left and right arrows vanish. (VF sends them with a display:none style attribute).

 

 

We have a custom text formula field on opportunity that looks like this:

HYPERLINK("www.google.com", "Click Here")

 

When you try to display this field on a visualforce page it displays the entire HTML code rather than "Click Here":

<apex:page standardController="Opportunity"> <apex:pageBlock mode="view"> <apex:pageBlockSection > <apex:outputField value="{!Opportunity.Hyperlink_Test__c}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

 

Displays:

<a href="www.google.com" target="_blank">Click Here</a>

 

Looks like a potential bug.

 

-Thanks,

Jason

  • February 20, 2009
  • Like
  • 0