• Acronym
  • NEWBIE
  • 25 Points
  • Member since 2007

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

I feel like a total n00b asking this question as the concept of public, global, static keywords seems pretty basic but are there any negatives to declaring class variables as static?

 

I have an asynchronous method that needs to access variables in the class but the only way for this static @future method to see the variables is to make them static. Is this acceptable? Is there a better way? See example below.

 

public class EmailDomains {

//Only way for @future method can see these variables is to make then static
static List<Account> accountsToUpdate = new List<Account>();
static Set<String> currentEmailDomains;
static Set<String> emailDomainsAfterClean;

//Called from trigger, visualforce, etc
@future
public static void rescanAccounts(Set<Id> acctIDs){
//Do cool stuff
//need to access list variables above
}
}

 

I suppose when you are self taught you miss some programming basics.

 

Thanks,

Jason

Message Edited by TehNrd on 02-05-2010 01:08 PM
  • February 05, 2010
  • Like
  • 0

I feel like a total n00b asking this question as the concept of public, global, static keywords seems pretty basic but are there any negatives to declaring class variables as static?

 

I have an asynchronous method that needs to access variables in the class but the only way for this static @future method to see the variables is to make them static. Is this acceptable? Is there a better way? See example below.

 

public class EmailDomains {

//Only way for @future method can see these variables is to make then static
static List<Account> accountsToUpdate = new List<Account>();
static Set<String> currentEmailDomains;
static Set<String> emailDomainsAfterClean;

//Called from trigger, visualforce, etc
@future
public static void rescanAccounts(Set<Id> acctIDs){
//Do cool stuff
//need to access list variables above
}
}

 

I suppose when you are self taught you miss some programming basics.

 

Thanks,

Jason

Message Edited by TehNrd on 02-05-2010 01:08 PM
  • February 05, 2010
  • Like
  • 0

When you use apex:selectList or apex:inputText you get this nasty error message. Something like this:

 

 

I could live with this for internal apps but I am now working on a force.com site that will face customers and partners so this won't fly.

 

Is there anyway to clean this up? I have many other apex:inputFields with required set to true so I can't do inspection on the apex side to see if the field is null and then display a nice clean message as the requiredness of the other fields prevents the apex from executing.

 

Any ideas? Workarounds?

 

Thanks,

Jason

 

  • January 26, 2010
  • Like
  • 0

I have a checkbox on the case object that, when checked, I want to put a check in another checkbox on a custom object.  I can't do this through workflow b/c of the relationship between the Cases object and the custom object.  So I'm assuming that the best way to do this is via a trigger, which I've never done but am eager to learn.  Basically, it needs to do this:

(Preface: the case will be entered from a record in a custom object called Request; and will, therefore, be related to the Request.)

If Hold_Addressed__c (custom field on Cases object)=TRUE,  then look at the request with which the case is related and update Hold__c (custom field on the Request object) to TRUE.

 

Any suggesstions are appreciated.

 

Thanks

Message Edited by crob1212 on 01-03-2010 11:35 PM

we're running into an issue where we're hitting errors like "unable to gain exclusive access" when triggers and apex are being fired off.  i started looking into pulling the code out of the triggers and loading it into standalone Apex classes with @future methods, but, the more I dig, the more it looks like I'll have to do a complete rewrite.

 

example

 

I have a trigger that fires AfterInsert on Case.  It looks to see if a contact is assigned to the Case, and if not, creates one based on Case.SuppliedEmail and Case.SuppliedName, then assigns it and updates the Case.  Part of this creation involves a Contact helper class I wrote for doing various things on the Contact object.  For instance, ContactUtils (the class) has a method called exists(string email) that returns true or false depending on whether the Contact exists.  I can't convert this method to @future unless I change it from returning a boolean to being both static and void.

 

I couldn't find a lot of detailed strategy around using @future with triggers, and even more so, ensuring "bulkification", which I'm sorry to say that this doesn't currently do.  We don't batch import Cases, so bulk isn't currently an issue, but I'd also like to get the code prepped and ready for that to ensure future issues do not come up.

 

Any thoughts on strategy here?

I have a VF page with showHeader="false" sidebar="false".  Inside it I'm starting at the <html> element, as can be done when showheader="false".  I'm also delcaring some xml namespaces, which subsequent elements belong to. The problem is that the VF compiler thinks that a namespace'd element *must* be a reference to a VF component.  Well, in my case it's not; it's just an xml element in a namespace.  The error message is:

 
Save error: The prefix "x" for element "x:p" is not bound. at line 1

 

Is there some way to relax the VF compiler?  Is VF compatible with xhtml and namespaces?

 

thanks

 

Jeremy Ross

I have created a custom field on the Lead object called LegacyId.

This query works fine (Java code):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website", "Lead", new String[] {id});

But this one, not so well (error is down at the bottom):
   SObject[] sObjects = binding.retrieve("Id, FirstName, LastName, City, State, Company, Email, Website, LegacyId__c", "Lead", new String[] {id});

Obviously, trying to figure out why.

Oddly, it used to work until I changed the label on my custom field.  I have since deleted it and created a new one but I'm still stuck with my error.  Note that if I do a describeSObject("Lead") I do see my field name.

When it was working, I was trying to figure out how to get the value out of my result set.  Obviously, there was no method called lead.getLegacyId__c().  I tried to get it via reflection but that didn't work either.  (No surprise there)  But I couldn't find another way.  While I'm asking questions I thought I'd throw that in there.


The error:
[ERROR] Exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.sforce.soap.enterprise.SoapBindingStub.retrieve(SoapBindingStub.java:3309)
    at com.vistage.salesforce.ToddTest.retrieveLead(ToddTest.java:92)
    at com.vistage.salesforce.ToddTest.findRecentUpdates(ToddTest.java:58)
    at com.vistage.salesforce.ToddTest.sfTests(ToddTest.java:38)
    at com.vistage.salesforce.ToddTest.<init>(ToddTest.java:27)
    at com.vistage.salesforce.ToddTest.main(ToddTest.java:212)
An unexpected error has occurred.; nested exception is:
    org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.Lead - LegacyId__c
  • November 12, 2007
  • Like
  • 0
I'm using the retrieve call thru the API to return a pdf file stored in the Document object.
 
I have successfully retrieved the fields from the Document object and displayed them on the page.  But, I am not able to decode the body field base64 string and display the content on the page?
 
This is what I have:
 
private void retrieve()
    {
        // Invoke retrieve call and save results in an array of SObjects
        sObject[] records = sfdc.retrieve("Name, Type, Description, ContentType, BodyLength, Body", "Document", new String[] { "01570000000GXCZ" });
        // Iterate through the results
        for (int i = 0; i < records.Length; i++)
        {
            Document document = (Document)records[i];
            // Get the document properties
            Label1.Text = "Name is: " + document.Name + "<br />" +
                "Type is: " + document.Type + "<br />" +
                "Description is: " + document.Description + "<br />" +
                "ContentType is: " + document.ContentType + "<br />" +
                "BodyLength is: " + document.BodyLength + "<br />" +
                "Body is: " + document.Body;
        }
    }
protected void LinkButton1_Click(object sender, EventArgs e)
    {
        login();
        retrieve();
    }
 
When I run the page, this is what displays:
 
Name is: Odyssey System Requirements November 2007 Full
Type is: pdf
Description is: Supported Odyssey System Requirements updated for November 2007
ContentType is: application/pdf
BodyLength is: 116243
Body is: System.Byte[]
 
I've tried: Convert.FromBase64String(bodystring);, but that doesn't work.
 
Anyone know how I can decode and display the content for the Base64 string stored in the body field of the Docment object?
 
Thanks.
Hi,
I have developed a application that runs on an external server. This application is embeded in the Salesforce site using "Display in existing window with sidebar" behaviour of "Custom Button or Link" option. This application has a close button in one of its GUI. When this close button is pressed I want it to return to the "All Opportunities" view.

1) How could I achieve this through an API call?
2) Also I want to later make this application an AppExchange application. Will your solution proposed for (1), will be get affected by this new situation?

Viraj
  • November 09, 2007
  • Like
  • 0
Hi,
Is there a way to create a view using API calls ?

Eg: I want to create a view named "Probability >= 90%" in the "Opportunities" tab.
In this view I want show "Opportunity Name", "Account Name", "Amount" of opportunities which has probability >= 90.
Please teach me how to do the above using API calls.

Viraj
  • November 09, 2007
  • Like
  • 0
perhaps i'm doing this incorrectly, but I'm trying to grab the User name using the following code:

Code:
for (var i:int=0;i<qr.records[j].Responsible_Party__r.records.length;i++)
{
  partyArray.addItem( { id:qr.records[j].Checklist_Comment__r.records[i].Id, who:qr.records[j].Checklist_Comment__r.records[i].User__r.Name, item:qr.records[j].Checklist_Comment__r.records[i].Checklist_Line_Item__c
} ); }

 
I keep getting "TypeError: Error #1010: A term is undefined and has no properties." on the "who" line of the addItem method.  I know it's there because I've debugged it in Flex and I've tested the SOQL query in apex explorer 8.0. 

Any ideas?
Hate to ask such a basic question. My company has all our account info in Sales Force and it works great for them.. they want me to integrate some data points from sales force into our backoffice app. No problem I have developer acocunt and I can attach to it - pull down the data.  My question is I don't know the sales force 'level' we have purchased. My guess is just basic or professional.  Is there a way for testing to get our current Salesforce databaes in a sandbox so I can test my code against 'real' data?

is there a sample using a relationship query in .net you can point me to?  I have looked all through the forums but can’t find anything for .net… I have something like this from the samples…

Code:

private string getFieldValue(string fieldName, System.Xml.XmlElement[] fields) {
    string returnValue = "";
    if (fields != null) {
        for (int i = 0; i < fields.Length; i++) {
            if (fields[i].LocalName.ToLower().Equals(fieldName.ToLower())) {
                returnValue = fields[i].InnerText;
            }
        }
    }
    return returnValue;
}

My function…
 
string q = "Select a.Id,a.Name,a.Field1__c,a.Field2__c," +
    "(Select d.Id,d.Name,d.Related_Field1__c,d.Related_Field2__c From MyRelatedObject__r d) " +
    "From MyCustomObject__c a";

QueryResult qr = m_binding.query(q);
sObject sobj = null;

for (int i=0; i<qr.records.Length; i++) {
    sObject record = qr.records[i];

    string objId = getFieldValue("Id", record.Any);
    string objName = getFieldValue("Name", record.Any);
    string objField1 = getFieldValue("Field1__c ", record.Any);
    string objField2 = getFieldValue("Field2__c ", record.Any);

    //how do I access the related object query results—
    //can I use QueryResult again or do I have to use xml methods to get at the sub results–
    //I want to get at the fields below…
    string relatedObjId = getFieldValue("Id", subrecord.Any);
    string relatedObjName = getFieldValue("Name", subrecord.Any);
    string relatedObjField1 = getFieldValue("Related_Field1__c", subrecord.Any);
    string relatedObjField2 = getFieldValue("Related_Field2__c", subrecord.Any);


 

Thanks for any help you can provide as I am stuck…

Hello Friends,
 
I successfully uploaded my WSDL into my Salesforce org. Now how can i access this Webservice from some other application outside saleforce??
 
Kindly help....
 
Best Regards,
Cool_D
Hi,
 
I am using the web service API version 7.0. I am able to access some of the custom objects and fields created in SFDC. I cerated a new custom object in SFDC. I am unable to access the newly created custom object. How to access this custom object through .net code.
 
Please help.
 
Regards.
Rathish
I am using C#.NET 2.0. I need to access the data within a QueryResult record without casting the sObject to a SFDC Object (like User) class. I need to roll through the individual data elements of a given record in a systematic manner independent of what the underlying SFDC Object (User) actually is. I will know the names of the individual data elements because of the query's column listing.
 
For example, something like...
DataRow dr;
dr = dt.NewRow();
sObject drQR = qr.records[x];
dr[
"ID"] = drQR["ID"];
 
Edwin Farrar
We have an application in c# that uses the sales force api to communicate with sales force. When the code is compiled and published, it works fine. Then after a couple of hours or a day, the code generates the following error:

INVALID_FIELD: No such column 'CurrencyIsoCode' on entity 'Opportunity'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

To get rid of the error, all we need to do is re-compile the code and publish it again. It will work fine for a couple of hours, then it will generate the exact same error mentioned above.

We now have two applications that suffer from the exact same issue. We have many other applications that communicate with Sales Force and they don't have this problem!!!

Please advise
I've successfully created a form in Flex to insert leads to my sf account. But I'm having trouble figuring out how to assign a campaign to the new lead added.

Thanks,
Dusty
  • October 30, 2007
  • Like
  • 0