• h8r41d
  • NEWBIE
  • 30 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 43
    Replies

Hi,

Can I do something like this in APEX:

 

update leads set company='MyCompany' where fname="myself";

 

This would update mutiple records with the one line command.

 

This of course is standard SQL syntax. Wondering if this is possible on the Force.com platform.

 

Regards

 

-Haroon

I need to enable attachments for a customer portal, but SF natively doesn't support this.

 

Anyone know of a workaround?

  • February 12, 2013
  • Like
  • 0

 

Hey guys, I have a question about javascript and custom buttons.

 

Basically, on a standard layout (NOT visualforce), I need a custom Save button that will perform the standard save operation, but instead of redirecting, will display a prompt asking the user if they want to add a related record. If so, redirect to the create new page, otherwise, go to the regular detail page.

 

Can somebody point me in the right direction for how to get started on something like this? Any examples available?

  • February 05, 2013
  • Like
  • 0

 

We recently build a small portal page for a client that displays some record data out of an object that is part of a third party managed package. 

 

When testing in the sandbox environment, all of the data is visible and accessible. In production, despite pouring over the permissions settings and verifying both in the profile setup page and portal health checker that the object has create/edit/delete permission and the proper fields are enabled in the field-level permissions, the portal user is still not able to see any data.

 

We've also verified that the fields we need are visible in the standard layout and that the tab is enabled.

 

Does anyone else have any other suggestions as to what may be overriding the permissions on this object? 

  • January 25, 2013
  • Like
  • 0

So the SF docs say that by default a testmethod has no access to organization data. I'm trying to run a test that directly assumes that the only data in my object is the data that I insert during the test method. However, no matter what I do, I can still select all existing data in the object!

 

There was another question about this posted a while back, but the problem there was that he was working with the users object, which apparently doesn't count. Here, I am working with a custom object.

 

This is a reduction of what I'm working with:

 

@isTest(SeeAllData=FALSE)
private class WOQuarantine_test {

	static testMethod void TestWOQuarantineController() {
		
		geocode_cache__c[] test = [select id from geocode_cache__c];

             system.debug(test.size());  // should be 0!!!
     }
}

 

Can somebody help me understand what I might be doing wrong? I know that seeAllData is supposed to be false by default, but the parameter seems to be having zero effect.

  • January 09, 2013
  • Like
  • 0

 

So, I'm assuming it's well known that you cannot un-center the body text of an email template that is set up using an html letterhead through the standard interface. 

 

The most common fix for this is to use the data loader or IDE to change the html content in the database. 

 

THE PROBLEM with this is that if you're using group edition, you cannot do this. So you're stuck.

 

Another suggestion is to simply use a custom letterhead and build the HTML yourself. That's fine, I can do that.

 

BUT THEN when you try to use the custom letterhead email template in the "Send an Email" section under contacts, there is no editable content area to type your message. 

 

Is there a way to add this editable area to the custom letterhead template? Some kind of code I'm unaware of?

  • January 04, 2013
  • Like
  • 0

Hi all

 

I've got a SF to SF connection established with cases, accounts, and contacts published and mapped.

 

According to the SF documentation, child records are supposed to be automatically shared.

 

However, when I transfer cases, the contact info is showing up blank.

 

Can anyone give me any clues as to why the child records are not sharing?

My Visualforce test page:

 

<apex:page sidebar="false" showHeader="false">
<c:ideas_email_digest email="{!$CurrentPage.parameters.email}" mode="Weekly"/>
</apex:page>

 

The Visualforce component:

 

<apex:component controller="ideas_digest_component_controller" access="global">
	<apex:attribute type="String" name="email" assignTo="{!context_user}" description="email address for context" /> 
	<apex:attribute type="String" name="mode" assignTo="{!digest_mode}" description="Digest type can be Weekly or Monthly"/>

{!context_user}   <-- Loads

{!mode} <-- Loads

//.... rest of page

</apex:component>

 

Component controller:

 

public class ideas_digest_component_controller {

	// stuff for the visualforce page
	public string context_user {get; set;}
	public  string digest_mode { get; set; }


// Constructor
public ideas_digest_component_controller() {
		
		if(context_user==null) {
			system.assert(false);  // <-- Always get here
		}
}

///... rest of code irrelevant

}

 

 

My question is, on the VF test page, the class properties are set and will display on the page. However, in the class constructor, the property values are still null.

 

At what point are these values populated? Why are they null in the controller? They are used to load dynamic data for the vforce page.

I have a client who has some code that automatically adds a notes task when a case is closed. It works fine except when a portal user closes their case, then I get this error:

 

First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Portal user can't own an activity: []

 

Is there a way to get around this issue and still insert an activity record when running as a PU? Can I override the user session limitations and add records as a system admin in the class?

Visualforce page reduction:

<apex:inputText value="{!mytest[0]}"/>

 

Apex class :

Public class test {
     public List mytest {get; set; }

     public test() {
          mytest = new List<String> {'testing!!!', 'whatever!!!'};
    }
}

I get an unspecified error when I use arrays in my inputs.

Hey all

 

I'm try to build an interface that is dual purpose record viewer / editor. I'm running into the problem of not being able to go to the next page if some records aren't passing validation (though they are not edited). The data pre-dates the validation rules, so when you view them, you can't move to the next page.

 

Does the setcontroller automatically try to save records when you call next() ?

 

This is just some example code, I don't want the focus of what I'm doing to cloud the concept I'm trying to figure out.

 

code:

 

sobject[] something = [SELECT Contact.FirstName, Contact.Account.Name, contact.account.type from Contact];

 

I've used sobject[] here instead of contact[] because in my project the query is dynamic and could be from a different table.

 

My question is, how do I get the relationship field from this? Normally, I know you can do this:

 

string theName = something[0].Account.Name;

 

However, this results in the error: Field expression not allowed for generic SObject

 

How do I get around this?

  • April 29, 2012
  • Like
  • 1

Hey all

 

I'm try to build an interface that is dual purpose record viewer / editor. I'm running into the problem of not being able to go to the next page if some records aren't passing validation (though they are not edited). The data pre-dates the validation rules, so when you view them, you can't move to the next page.

 

Does the setcontroller automatically try to save records when you call next() ?

 

This is just some example code, I don't want the focus of what I'm doing to cloud the concept I'm trying to figure out.

 

code:

 

sobject[] something = [SELECT Contact.FirstName, Contact.Account.Name, contact.account.type from Contact];

 

I've used sobject[] here instead of contact[] because in my project the query is dynamic and could be from a different table.

 

My question is, how do I get the relationship field from this? Normally, I know you can do this:

 

string theName = something[0].Account.Name;

 

However, this results in the error: Field expression not allowed for generic SObject

 

How do I get around this?

  • April 29, 2012
  • Like
  • 1

I need to enable attachments for a customer portal, but SF natively doesn't support this.

 

Anyone know of a workaround?

  • February 12, 2013
  • Like
  • 0

 

Hey guys, I have a question about javascript and custom buttons.

 

Basically, on a standard layout (NOT visualforce), I need a custom Save button that will perform the standard save operation, but instead of redirecting, will display a prompt asking the user if they want to add a related record. If so, redirect to the create new page, otherwise, go to the regular detail page.

 

Can somebody point me in the right direction for how to get started on something like this? Any examples available?

  • February 05, 2013
  • Like
  • 0

I have apex code that populates fields, and I want to run the "before update" on all opportunities once a week to make sure that these fields that are populated are current.

I've created the scheduled batch apex in classes and have set it to schedule and run, and it's running but it isn't running the "before update" on all of my opportunities.

 

here's my scheduler:

global class batchitupson_schedule implements Schedulable {
global void execute(SchedulableContext scMain) {
BatchUpdateForecast clsBatchItUpSon = new BatchUpdateForecast('Select Id, Name FROM Opportunity','Opportunity','Source_Name__c','Gwins');
ID idBatch = Database.executeBatch(clsBatchItUpSon, 100);
}
}

 

and here is my Scheduled class that is batchable, as you can tell, all i want it to do is open all the opportunities and update them, much like if you were to click through them manually and click "Edit" then click "Save" which then runs my "before update" code for the opportunity

 

global class BatchUpdateForecast implements Database.Batchable<sObject>{

   global final String Query;
   global final String Entity;
   global final String Field;
   global final String Value;

   global BatchUpdateForecast (String q, String e, String f, String v){

      Query=q; Entity=e; Field=f;Value=v;
   }

   global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
     //for(sobject s : scope){
     //s.put(Field,Value); 
     //}
     update scope;
    }

   global void finish(Database.BatchableContext BC){
   }
}

 

Hello,

Can anyone help me correct this error? I am not a developer hoping someone can walk me through what steps to take to get this running correctly

Thank You,

Brian

 

8/28/2012 1:00 AM

 Batch ApexFailedFirst error: Inactive User, orgId: 00DA0000000BYaz userId: 005A0000001cdlv011 8/28/2012 1:00 AMDistributionListClass 707A000000QjvGg
  • August 28, 2012
  • Like
  • 0

Hi,

Can I do something like this in APEX:

 

update leads set company='MyCompany' where fname="myself";

 

This would update mutiple records with the one line command.

 

This of course is standard SQL syntax. Wondering if this is possible on the Force.com platform.

 

Regards

 

-Haroon

Hello,

 

I have a VF page using a pageBlockTable.  I would like to format the header ("GENERAL INFORMATION") to change the text color and background but none of the formatting I enter seems to work.  I'm pretty sure it's a simple thing, but I can't figure it out.  Any ideas?  Thanks,

 

        <apex:pageBlockTable columns="2" value="{!Client__c}" var="score" style="width:100%; font-size:14pt">

 

                <apex:column headerValue="GENERAL INFORMATION" style="width:60%; font-weight:bold; font-size:10pt">
                    <br>Client Name:</br>
                    <br>Watch List:</br>
                    <br>Projected Annual Revenue:</br>
                </apex:column>

 

                <apex:column style="width:40%; font-size:10pt">
                    <br><apex:outputlink value="https://cs1.salesforce.com/{!score.Client_Name__c}">{!score.Client_Name__r.Name}</apex:outputlink></br>
                    <br><apex:outputfield value="{!score.Watchlist__c}"/></br>
                    <br><apex:outputfield Value="{!score.Projected_Annual_Revenue__c}"/></br>
                </apex:column>
                    
        </apex:pageBlockTable>

  • August 28, 2012
  • Like
  • 0

Can anyone point me to an example of how to create and assign a territory manually to an account in a unit test?  I have created an account in my unit test, but I also need to manually assign a territory to the account.  So, I need to create the territory, the userTerritory and user record that will be assigned to the account.

 

How do you go about doing this in a unit test.  It doesn't appear you can perform DML on the Territory and UserTerritory objects in a unit test? 

 

Can anyone provide some help on how to accomplish this in a unit test?

 

Thanks.

What am i doing wrong here? Two Custom Objects: Account_Management__c (Parent) and Social_Media__c (Child)

 

<apex:page standardController="Account_Management__c" >
    <apex:relatedList list="Social_Media__r" />
</apex:page>

 Error:

Social_Media__r' is not a valid child relationship name for entity Account Management

 

Any Help would be great

Hey guys-

 

I have the following which has been driving me crazy:

 

I'm writing a test method for a custom controller, and the second try/catch always fails when I run the test.

 

The code works perfectly when invoked through VF, but the test method fails on the second try/catch every time...

 

Any ideas out there??

 

 

//Record Type could throw an error if the 'Name' has changed
        try{
            rt = [SELECT Id 
                         FROM RecordType 
                         WHERE Name = 'Standard Request'
                         AND SobjectType = 'Case' 
                         LIMIT 1];}
        catch(QueryException e1){error=TRUE;}
        
        //Contact record which matches the current user. Text field could be incorrect on User and throw an error
        //Cast to ID, then back to string, to get full 18 characters
        ID convertToLong = u.User_Contact_Link__c;
        String longId = convertToLong;
 
        system.debug('++++UserCon'+u.User_Contact_Link__c);
        system.debug('++++Long'+longId);
        
        try{
            c = [SELECT Id
                        FROM Contact
                        WHERE id = :longId
                        LIMIT 1];}
        catch(QueryException e2){error=TRUE;}
                  
        //If either exception occurs, then exit and throw a generic error.
        if(error == TRUE){
        
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'An error has occurred. Please open this ticket from the Change Request tab.'));    
            return null;
        }       

 

Hi,

 

We have a request to write a trigger to send out an email message at a specific time delay after a situation happened. Because of the complex logic this can't be done via workflow. Anyway to mimic those behavior in my own apex trigger code?

 

Thanks so much.

Hi,

 

I have three custom objects: Aspirante__c, Vacante__c and Asignados__c. The Asignados__c object has a master-detail relationship with Aspirante__c and also has a master-detail relatonship with Vacante__c. I want quering from the Asignados__c object the name of Aspirante__c and the name of Vacante__c. I have the next query:

 

List<txmrecruitment__Aspirante__c> arbolvacs = [Select
   (Select Name From txmrecruitment__Vacante__c.Vacantes_Aspirantes1__r)
   From txmrecruitment__Asignados__c];

 

I am receiving the error:

Error: Compile Error: Didn't understand relationship 'txmrecruitment__Vacante__c' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 23 column 51

 

Thanks for any help!

Hi All

 

 

Visualforce Error
 

System.NullPointerException: Attempt to de-reference a null object

Error is in expression '{!Add}' in component <apex:page> in page fconnect:selected_products_underservice

 

 

Class.FConnect.SelectedProductsunderservice.Add: line 78, column 1

 

 

<apex:page controller="SelectedProductsunderservice">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons id="id">
<apex:commandButton value=" Add " action="{!Add}" reRender="id"/>
<apex:commandButton value="Cancel" action="{!cancel}" reRender="id"/>
</apex:pageBlockButtons>
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!ProductsUnderService}" var="ip" id="table">
<apex:column >
<apex:inputCheckbox value="{!ip.selected}"/>
</apex:column> 

<apex:column value="{!ip.con.Name}"/>
<apex:column value="{!ip.con.Products__c}"/>
<apex:column value="{!ip.con.Description__c}"/>
<apex:column value="{!ip.con.Serial_ID__c}"/>
<apex:column value="{!ip.con.Asset_Tag__c}"/>
<apex:column value="{!ip.con.Quantity__c}"/>
<apex:column value="{!ip.con.Customer__c}"/>

</apex:pageBlockTable>
</apex:pageBlock>

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

 

 

 

 

public with sharing class SelectedProductsunderservice 
{
public String AgreementLineId;
public String Customer;
public String customerName;
Public List<Products__c> Products;
Public List<Product__c> customProducts;
public List<ProductsUnderService> ProductsUnderServiceList{get;set;}
List<Id> proIds = new List<Id>();
List<Id> iprodIds = new List<Id>();

public SelectedProductsunderservice ()
{
customProducts = new List<Product__c>();
AgreementLineId=apexpages.currentpage().getparameters().get('Agreement_Line');
Agreement_Line__c al=[select id,Agreement__r.Customer__r.name from Agreement_Line__c where id=:AgreementLineId];
Customer=al.Agreement__r.Customer__c;
customerName=al.Agreement__r.Customer__r.name;

Products = [SELECT id,name ,Agreement_Line__c,Products_ID__c FROM Products__c WHERE Agreement_Line__c=:al.id ];

for(Products__c pro : Products)
{
proIds.add(pro.Products_Id__c);
}

customProducts = [SELECT Id, Name FROM Product__c WHERE Id IN :proIds];
}

public List<ProductsUnderService> getProductsUnderService()
{
ProductsUnderServiceList=new List<ProductsUnderService> ();
List<Installed_Products__c> iproducts = [select Name,
Description__c,
Serial_ID__c,
Asset_Tag__c,
Quantity__c,
Agreement_Line__c,
Products__c,
Site__c,
Customer__c from Installed_Products__c where Customer__c=:customer AND Products__c IN:proIds limit 4];

For(Installed_Products__c ip :iproducts ) 

iprodIds.add(ip.Id);
}
List<Products_Under_Service__c> Productserrvice =[select id,name,Installed_Productss__c from Products_Under_Service__c 
where Agreement_Line__c=:AgreementLineId AND Installed_Productss__c IN:iprodIds ];

For(Installed_Products__c ip :iproducts ) 
{
integer i=0;
For(integer temp=0;temp<Productserrvice .size();temp++ )
{
if(Productserrvice[temp].Installed_Productss__c == ip.id)
i++;
}
if(i==0)
ProductsUnderServiceList.add(new ProductsUnderService(ip));

if(ProductsUnderServiceList.isEmpty())
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,+ 'There are no Installed Products for '+customerName+' Account'));
return ProductsUnderServiceList; 


public PageReference Add() 
{
List<Products_Under_Service__c> listPus; 
for(ProductsUnderService ip:ProductsUnderServiceList)
{
if(ip.selected==true)
{
Products_Under_Service__c pus= new Products_Under_Service__c(Installed_Productss__c=ip.id,
Agreement_Line__c =AgreementLineId);
//insert Pus; 
//listPus.add(pus);
}
insert listPus;
}
PageReference p=new PageReference('https://ap1.salesforce.com/'+AgreementLineId);
return p;
}
public PageReference cancel()
{
PageReference p=new PageReference('https://ap1.salesforce.com/'+AgreementLineId);
return p;
}

public class ProductsUnderService 
{
public Installed_Products__c con {get; set;}
public String id{get;set;}
public Boolean selected {get; set;}
public String aggreementLine{get;set;} 

public ProductsUnderService(Installed_Products__c ip)
{
id=ip.id;
con = ip;
selected = false;
}
}
}

 

 

Any help is Appriciated  

  • August 27, 2012
  • Like
  • 0

Hi..i am a newbie..and never worked with webservices

i am trying to write a trigger which gets triggered when a campaign is created and an email is sent to a praticular profile people.

As this will impact daily limit,i am using webservice

 

Any suggestion how to do it..

 

 

Any help highly  appreciated..

Thanks in advance

 

 

 

Hi, I have an Apex class that creates a PDF attachment for each id that it is passed.

This works great when only 50 or so IDs are passed in, but any more than that and I get a Heap error.

 

I read somewhere that I could create a webservice in Apex to get around this, but I can't find any documentation about calling a salesforce webservice from within the same salesforce org.

 

If anyone can point me in the right direction, or suggest a different solution, that would be greatly appreciated!

  • August 27, 2012
  • Like
  • 0

Hi Community,

 

I have a trigger that needs to match line items of the same custom object type and populate lookups to one another. The logic to find these matching items is straight forward, but I am wondering if I am overlooking the best way to actually populate the lookups.

 

The problem arises when one or both of the line items are being inserted (vs. updated), and therefore do not have access to a salesforce ID to use to populate the lookups in the context of the before trigger. These line items do have external Ids.

 

I tried populating the external ids in a reference to the other record in the trigger, and this seems to work when an actual insert DML statement is made in apex code - but does not work when used in the trigger (without a DML call). Example:

 

Line_Item__c first = new Line_Item__c();

Line_Item__c second = new Line_Item__c(External_ID__c = 'externalId2');

first.Line_Item__r = second;

 

This seemingly does not work in a trigger.

 

My thought now is to use an @future method. When the items are matched in the trigger, it will pass the two external id's of the line items to the @future method which will query the database for the correct ids and populate the lookups, and finally update the line items. 

 

Is there a better way to do this? Any help is appreciated. 

Has anyone else noticed that line number scrolling broken in Eclipse 3.4 on Mac OS? I did read one blog post that identifies the issue. This makes it EXTREMLY hard to track down errors by line number. Eclipse 3.5 is rumored to work fine.

 

Can anyone comment on when the Force.com IDE might work with Eclipse 3.5?

  • October 11, 2009
  • Like
  • 0

I am exporting an Excel document on a button click The document gets exported to Excel in proper format in Windows.

 

But when I try to do the same in MAC OS I get  a top mline on the excel sheet with a jumble of computer code in the top.The document I want is produced fine after that.

 

My VF page code:->

<apex:page controller="InvoiceDataExportController" contenttype="application/vnd.ms-excel"
title="Invoice Export"
>
    <apex:pageBlock title="Invoice Details">
        <apex:pageBlockTable value="{!InvoiceDetails}" var="invDetail" border="1">
            <apex:column headerValue="Invoice Number" value="{!invDetail.First}" />
           
            <apex:column headerValue="Supplier" value="{!invDetail.Fifteenth}" />
            <apex:column headerValue="Purchaser" value="{!invDetail.Twelth}" />
            <apex:column headerValue="Invoice Date" value="{!invDetail.Sixteenth}" />
           
            <apex:column headerValue="Confirmed at Purchaser" value="{!invDetail.Seventh}" />
            <apex:column headerValue="Confirmed at Supplier" value="{!invDetail.Eighth}" />
           
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

The gibbersih code that I have at the top is :->

 

if(!window.sfdcPage){window.sfdcPage = new ApexPage();} UserContext.initialize({'isAccessibleMode':false,'ampm':['AM','PM'],'locale':'en_US','dateTimeFormat':'M/d/yyyy h:mm a','today':'1/16/2009 1:31 AM','dateFormat':'M/d/yyyy','language':'en_US','siteUrlPrefix':'','userPreferences':[{'value':false,'index':119,'name':'HideUserLayoutStdFieldInfo'} ,{'value':false,'index':87,'name':'HideInlineSchedulingSplash'} ,{'value':false,'index':116,'name':'HideRPPWarning'} ,{'value':false,'index':115,'name':'DefaultTaskSendNotification'} ,{'value':false,'index':114,'name':'OverrideTaskSendNotification'} ,{'value':false,'index':112,'name':'HideInlineEditSplash'} ],'startOfWeek':'1'} );