• Iceman123
  • NEWBIE
  • 200 Points
  • Member since 2008

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 28
    Replies

I am using the Force.com WSC connector for Java.

 

Is it possible to return a list of fields or field names from a QueryResult's SObject?  I only see getField (which requires that I hardcode the name of the field of interest).  I am looking for something like getFields which returns an array of field objects or field names, etc..

 

I could go through and parse the select field statement to determine these names based on the query the user enters.  I just want to check here to see if there's a way to identify the list of fields requested from the QueryResult object.  Any feedback is appreciated.

 

thanks

We are evaluating Email to Case (On Demand).   It looks like the way it works out of the box is when we forward emails from support@company.com to the SF routing address, because the FromAddress for all the forwards is set to support@company.com, then all cases created via Email to Case (On Demand) will automatically have the Contact field set to a contact record for support@company.com (instead of the actual customer contact account for the person who sent the original email to support@company.com).  

 

What is the recommended (best practice) way to tackle this without having to write something like an after Insert case trigger to update the Contact relationship and parsing the TextBody of the email from the EmailMessage object to determine the true "sender"'s email address?

 

thx!

 

Hi there,

 

I am trying to figure out the right design for a business requirement.

 

Requirement:

- To be able to maintain/configure a dependent picklists to be used/shared across different objects (standard or custom). 

 

Use Case:

- We are using Salesforce to track product bugs (custom object) and customer cases (standard Case object).  We currently have product and version picklists defined for both Product Bug and Case objects, where the version picklist is dependent on the product selected.  These picklists in the Product Bug and Case objects have identical values and dependency.  So we are essentially duplicating the same functionality in both.

- We would like to be able to have a single place to maintain the values of these picklists so that an admin will not have to make the same change to both objects.

 

What are the different options available to implement this?  

- Is it better to use Custom Settings to store mappings for each selection and then handle the dependency effect using Visualforce's rendering capability (ie. without actually using the dependent picklist feature)?

- Or do we create inputFields on the Product Bug page bringing back the dependent picklists for the Case object, but in the get/set methods, set the values selected against the Case object inputFields to the corresponding/identical fields in the Product Bug object (ie. just use the Case object to populate the values (no save) for the UI but update the identical Product Bug fields in the backend)?

 

Any guidance is appreciated :)

 

thanks!

~P

Hi there,

 

We are trying to implement a new custom object to store product defects.  We have 1 requirement we are not sure if it requires customization.  The specific requirement is the following:

 

- The ability to relate product defects to each other (ie. records within the same object) by selecting existing defects in the system.

- A *single* related list (eg. "Related Defects") on the product defect layout to show all "linked" product defects, eg. if DefectA is linked to DefectB and DefectC, DefectA's related list will show B and C, DefectB's related list will show A and C, and so on.

 

Can this be done without customization?

 

thanks

Hi there,

 

I have the following test code which updates a field in a related object (CustomObject__r).  The CustomObject is related to Opportunity and the code below runs through successfully.

 

Opportunity o = [select CustomObject__r.Market__c,StatusMessage__c from Opportunity where Id='00600000008HFNLAA5'];
           o.CustomObject__r.Market__c = 'test';
           o.StatusMessage__c = 'test update';
           
            try
            {
                Database.SaveResult srs = Database.update(o);
                if (srs.isSuccess())
                {
                     // successful
                }
            } catch (Exception e) {
                    ApexPages.addMessages(e);
            }      

 

The above code does not return an exception and also is successful based on the return value of isSuccess().  The StatusMessage__c in the main object is successfully updated, but the CustomObject__r.Market__c field does not get updated even though the update transaction as a whole is deemed successful.  Any troubleshooting ideas, or if the above update is not possible (ie. have to fetch back and update CustomObject__c directly)?

 

thanks

I think I am overlooking something simple here, any help is appreciated.  Here is an isolated example (as you can see, the trigger doesn't actually do anything, it's trimmed down to just show the problem).   The testmethod runs fine with 100% coverage when testing against the sandbox environment.  

 

During deployment validation (when attempting to deploy to production), when the testmethod gets to the insert statement for the case, it goes into the trigger as expected (after insert), but it gives a "list has no rows" error in the trigger (when it attempts to query for the contact associated to the case).  But the contact is created at the beginning of the testMethod and associated to the case before the insert statement so I would expect that the validation process would find this contact because it is created and associated to the case as part of the testmethod.  Can anyone tell me why it cannot locate the contact during the deployment process?

 

thanks!

Pi

 

---------------

trigger testTrigger on Case (after insert) {

    for (Case c:Trigger.new)
    {
        Contact contact1 = [select AccountId from Contact where Id=:c.ContactId]; //caused by: System.QueryException: List has no rows for assignment to SObject
    }

}

 

 

    static testMethod void myUnitTest() {

        Test.startTest();
        Account a = new Account();
        a.Name='Test Account';
        a.Industry = 'Automotive';
        insert a;
        
        Contact contact1 = new Contact();
        contact1.FirstName = 'First';
        contact1.LastName = 'Last';
        contact1.AccountId = a.Id;
        insert contact1;        

         Case case1 = new Case();
         case1.ContactId=contact1.Id;
         case1.Subject='test Subject';
        insert case1;         
        
        system.assertEquals(a.Id,[select AccountId from Contact where Id=:case1.ContactId].AccountId);
        Test.stopTest();
    }

Hi there,

 

Can rendered attributes handle Set .contains method?

 

I have the following rendering code that works in a simple string comparison case.

 

String myId ...

<apex:outputPanel id="editPanel" layout="none" rendered="{!o.Id == myId}">

 

But I have a requirement to only render the panel if o.Id is contained in a predefined String Set, but the call fails with the error "Unknown function myListOfIDs.contains...." when I try using the rendered code below.

 

Set<String> myListOfIds ....

 

<apex:outputPanel id="editPanel" layout="none" rendered="{!myListOfIds.contains(o.Id)}">

 

Is there a way around this other than creating a bunch of separate variables and use AND to come up with a long comparison string clause? :)

 

thanks and happy holidays!

Pi

Hi there,

 

I am looking for feedback from folks who have deployed the email2case on-demand solution.  We are evaluating e2c on-demand.  How flexible is this module from the perspective of customization?  For example, can the following be customized?

 

1.  Only create cases for valid contacts in the system

2.  Auto reply with a registration link for unknown contacts

3.  Use a different ID format instead of the ref id as the unique identifier

 

I think for #1 and #2, it seems like it is only possible if there's a way to inject custom apex code after it parses the email but before it creates the case?

 

thanks

~P

hi there,

 

I have a simple question.  I know how to throw errors from apex triggers by using the sObject.addErrors method.  This gets displayed on the UI as a red error message.   Is there a way to throw info level messages that show up as a non-critical message?  Or will I have to write something custom like set the info messages in a field from the trigger and display that field in a info message section on the UI?

 

thx,

Pi

I have the following working query which fetches back case comment activities for a set of accounts:

 

select AccountId from Case where Id in (select ParentId from CaseComment where ......) and AccountId in :accountMap.keyset()

 

except that I end up with duplicate AccountIds which means that it is unnecessarily eating up the governing limits for # of queried rows.  While functionally, I can use a group by statement to get the distinct accountIds, group bys do not affect the queried rows limit for it is simply a filter over the queried rows.

 

If this is sql, I could have used something like the following but nesting is not supported as noted in documentation: select Id from Account where Id in (select AccountId from Case where Id in (select ParentId from CaseComment  where ....)) and Id in :accountMap.keyset().

 

Can anyone think of a governing-limit-efficient workaround that will give the right distinct account ids?

 

thanks!

Pi

SELECT Name, (SELECT lastname FROM Contacts WHERE CreatedBy.Alias = 'x') FROM Account

 

Take the above example, is there a way (in SOQL only) to only return Account rows where the child relationship subquery ((SELECT lastname FROM Contacts WHERE CreatedBy.Alias = 'x')) is not empty (ie. contains at least 1 child object row)?

 

thanks

Pi

HI there,

 

We have built an integration to a 3rd party system using HTTPs.  This integration requires CA signed certificates (cannot use self-signed certificates from Salesforce).  Everything is working well, except that Salesforce deletes all CA signed certificates on every full sandbox refresh, which means that we will have to spend hundreds of dollars to generate a new CSR from Salesforce and have the CA sign them every time we do a refresh of the data.  This can get very expensive in the long run if we are to maintain this test/QA/sandbox environment.  Is there a workaround to this?

 

thanks,

Pi

hi there,

 

I have spent many hours on this and can't figure out why Visualforce has trouble with YUI Panel renders when using repeater components.  Here is my isolated repro test case:

 

 

<apex:page controller="TestYUIC" tabStyle="Account" sidebar="false">

<apex:styleSheet value="http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/skin.css" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/container/container-min.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js" />
 
<script>

    YAHOO.namespace("force.com");

    YAHOO.force.com.showMe = function() {
        document.getElementById("myDialogPanel").style.display = "block";
        YAHOO.force.com.myDialog.show();
    }
   
    function passToShowMe(repeaterString)
    {
        passToController(repeaterString);   
        var elementID = "DialogHere" + repeaterString;
        YAHOO.force.com.myDialog.render(document.getElementById(elementID));
        YAHOO.force.com.showMe();
    }    

    YAHOO.force.com.hideMe = function() {
        YAHOO.force.com.myDialog.hide();
    }
 
    YAHOO.force.com.init = function() {
        document.body.className = document.body.className + " yui-skin-sam";
       
        YAHOO.force.com.myDialog = new YAHOO.widget.Panel(
            "myDialogPanel",  // The id of our dialog container
            {
                    width           :   50,    // You can play with this until it's right
                    visible         :   false,  // Should be invisible when rendered
                    draggable       :   true,   // Make the dialog draggable
                    close           :   false,  // Don't include a close title button
                    modal           :   false,   // Make it modal
                    fixedCenter     :   false,   // Keep centered if window is scrolled
                    zindex          :   40,     // Make sure it's on top of everything
                    constraintoviewport    :    true,           
            }
         );
    }
   
    YAHOO.util.Event.addListener(window, "load", YAHOO.force.com.init);
</script>

<apex:form id="MainForm">
<apex:repeat value="{!repeaterStrings}" var="s" id="StringRepeater">
        <input id="Button{!s}" type="button" class="btn"
                    onclick="passToShowMe('{!s}')"
                    value="{!s}" />
        <div id="DialogHere{!s}"></div>
        <apex:actionFunction name="passToController" action="{!DoSelect}" rerender="dialogPanel">
            <apex:param name="FruitSelection" value="" />
        </apex:actionFunction>            
</apex:repeat>   
</apex:form>

<apex:form >
<div id="myDialogPanel" style="display: none" >
     <apex:outputPanel id="dialogPanel" layout="block">
  <div class="hd">
    <apex:outputText value="{!Fruit}" />
  </div>
  <div class="bd">
        <div style="text-align: center;" >
          <apex:commandButton value="Close" immediate="true" oncomplete="YAHOO.force.com.hideMe();"/>
        </div>
  </div>
    </apex:outputPanel>
</div>                                  
</apex:form>

</apex:page>

 

 

public class TestYUIC {
   
public List<String> repeaterStrings = new List<String>();
public String Fruit {get; set;}

      public TestYUIC()
      {
          repeaterStrings.add('Apple');
          repeaterStrings.add('Strawberry');
          repeaterStrings.add('Banana');
          repeaterStrings.add('Mango');
      }
     
      public void DoSelect()
      {
          Fruit = Apexpages.currentPage().getParameters().get('FruitSelection');
         
      }     
     
      public List<String> getrepeaterStrings()
      {
          return repeaterStrings;
      }
}

 

 

Based on the view source of the page, the above code correctly generates a set of unique div tags intended for panel placements, eg.  DialogHereApple, DialogHereStrawberry, and so on.

 

        <input class="btn" id="ButtonApple" onclick="passToShowMe('Apple')" type="button" value="Apple" />
<div id="DialogHereApple"></div><script id="j_id0:MainForm:StringRepeater:0:j_id7" type="text/javascript">passToController=function(FruitSelection){A4J.AJAX.Submit('_viewRoot','j_id0:MainForm',null,{'similarityGroupingId':'j_id0:MainForm:StringRepeater:0:j_id7','parameters':{'j_id0:MainForm:StringRepeater:0:j_id7':'j_id0:MainForm:StringRepeater:0:j_id7','FruitSelection':FruitSelection||''} ,'actionUrl':'https://c.cs0.visual.force.com/apex/TestYUIP'} )};
</script>
        <input class="btn" id="ButtonStrawberry" onclick="passToShowMe('Strawberry')" type="button" value="Strawberry" />
<div id="DialogHereStrawberry"></div><script id="j_id0:MainForm:StringRepeater:1:j_id7" type="text/javascript">passToController=function(FruitSelection){A4J.AJAX.Submit('_viewRoot','j_id0:MainForm',null,{'similarityGroupingId':'j_id0:MainForm:StringRepeater:1:j_id7','parameters':{'j_id0:MainForm:StringRepeater:1:j_id7':'j_id0:MainForm:StringRepeater:1:j_id7','FruitSelection':FruitSelection||''} ,'actionUrl':'https://c.cs0.visual.force.com/apex/TestYUIP'} )};
</script>

 

The page simply displays 4 buttons on load.  I expect a dialog to render right after each button depending on the button I click on (because each button has an unique div tag after it for rendering). However, when clicking on the buttons, the panel always renders after the first button I click on ...

 

 

 

Say I click on the button for Mango first, the panel renders in the DialogHereMango div tag, but then if I click on the Apple button, the panel still renders in the DialogHereMango div tag.  If I put an alert tag after the line var elementID = "DialogHere" + repeaterString; in the passToShowMe function, it correctly shows the elementID passed on to the render method for each click.

 

Any YUI/VF experts out there who can help shed some light on why the YUI panel does not render in the targeted div tag when using apex:repeater component?

 

thanks,

Pi

 Has anyone used the new dom.Document class?  

 

            HTTPResponse res = http.send(req);
            dom.Document doc = res.getBodyDocument();

 

I am using it to fetch the xml response from a web service.  But it looks like it uses a lot of heap space.  Based on logging using Limits.getHeapSize, I see the following:

 

before http callout: 1380 bytes

right after HTTPResponse res = http.send(req): 902657 bytes

right after res.getBodyDocument(): 2999340 bytes (and it bombs out because it exceeded the 2Mb heap limit).

 

The response size coming back from the web service is a little under 900Kb (based on the raw response as recorded in SOAPUI).   Is it normal for getBodyDocument to produce a DOM object that is 2+ times the size of the raw response?

 

Pi

Hi there,

 

I am kind of new to SSL so any help is greatly appreciated. 

 

I have a self-signed certificate generated within Salesforce.  According to the documentation, when making HTTPs callout to a 3rd party service, I have to deliver this SF signed cert to the 3rd party.  This part makes sense because the 3rd party needs the cert to decrypt data that is encrypted by the private key associated to the cert (which SF has). 

 

But how about the response from the 3rd party system back to Apex?  It seems like the 3rd party system will need (in addition to the signed cert) the private key associated to the self-signed cert generated by SF to encrypt the data back to Apex?  Is this correct? If so, will I need the private key SF used to generate that specific cert in the first place?

 

thanks,

Pi

Hi there,

 

Sorry, I am not sure if URL state is the right terminology here, but I will try to explain what I am trying to do here :)


1.  The user brings up the VF page (eg. MyPage) with a parameter in the URL: eg. http://site/apex/Page?e=12
2.  Based on the value of e, the controller of the VF page (eg. MyController) runs some logic and populates the VF page as part of its MyController() method.
3.  On MyPage, there is a set of output links (or ahrefs) with different values for e, eg.
http://site/apex/Page?e=2
http://site/apex/Page?e=3
http://site/apex/Page?e=4
4.  When the user clicks on these links, say, http://site/apex/Page?e=2, I would like to take the current e parameter ie. e=12 and append it to the e parameter that is selected and redirect the page back to itself as the URL: http://site/apex/Page?e=2+12, so that new data will be populated on MyPage based on now 2 different parameter values.  And then if the user clicks on http://site/apex/Page?e=3, I would like to take 3 and append it to the current url "state", and redirect back to MyPage with e=2+12+3, and so on, etc..

 

I figure I have to store the "state" of the url somewhere.  I am thinking I could have an onClick event on each of the separate links in Step 3, which updates a List or Map that stores the current state of the URL (ie. the running total of e's).  So I created a public List variable to store the running list of e's selected in MyController.  In my onClick method in the controller, I perform a PageReference in an attempt to modify the URL ... but the problem here is that if I use a PageReference.setRedirect back to the same page with the right e string (eg. 2+12), the URL of the page (and getParameters()) shows only e=2 (the last selected one), which means that the code in Step 2 to populate the page will keep painting it with data related to the last selected e (ie. 2)

 

How would you tackle this use case (storing url state)?  Any feedback is appreciated.

Pi

Message Edited by Iceman123 on 01-15-2010 09:52 AM

Given the same VF page and Apex controller using a very simple example invoking the actionFunction, I am seeing that it works only in IE and not in Firefox.


The controller code:

public class TestAction {

public String ExposeID { get; set; }

public PageReference toggleItem()
{
ExposeID = Apexpages.currentPage().getParameters().get('firstParam');
system.debug('~~~~~~~~~ IN TOGGLE ITEM');

return null;
}


}

The page code:

<apex:page controller="TestAction" tabStyle="Account" sidebar="false">
<apex:form >

<a href="/apex/TestActionPage?expose=12" onclick="toggleItemJS('12');">Item 12</a>

<apex:actionFunction action="{!toggleItem}" name="toggleItemJS" rerender="showstate" >
<apex:param name="firstParam" assignTo="{!ExposeID}" value="" />
</apex:actionFunction>

<p><apex:outputText value="Item Exposed: {!ExposeID}" id="showstate" /></p>
</apex:form>

</apex:page>



When using IE as the client browser, the debug window shows:

 

------------------------------------------------------------------------

 

10:05:37 DEBUG -
***Begining Page Log for /apex/TestActionPage
Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

No profiling information for method invocations.


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:37 DEBUG -
***Begining Page Log for /apex/TestActionPage
Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

No profiling information for method invocations.


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:38 DEBUG -
***Begining Page Log for /apex/TestActionPage
20100107180537.295:Class.TestAction.toggleItem: line 8, column 8: ~~~~~~~~~ IN TOGGLE ITEM
20100107180537.295:External entry point: returning NULL from method public System.PageReference toggleItem() in 0 ms

Element j_id3 called method {!toggleItem} returned type PageReference: noneCumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

1 most expensive method invocations:
Class.TestAction: line 5, column 23: public System.PageReference toggleItem(): executed 1 time in 0 ms


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:38 DEBUG -
***Begining Page Log for /apex/TestActionPage
20100107180537.295:Class.TestAction.toggleItem: line 8, column 8: ~~~~~~~~~ IN TOGGLE ITEM
20100107180537.295:External entry point: returning NULL from method public System.PageReference toggleItem() in 0 ms

Element j_id3 called method {!toggleItem} returned type PageReference: noneCumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

1 most expensive method invocations:
Class.TestAction: line 5, column 23: public System.PageReference toggleItem(): executed 1 time in 0 ms


***Ending Page Log for /apex/TestActionPage?expose=12


------------------------------------------------------------------------
As you can see, it called the toggleItem function correctly.

But when I use a Firefox browser (tried 2.0 , 3.0 and 3.5), it only writes:

10:04:50 DEBUG - ***Begining Page Log for /apex/TestActionPage Cumulative profiling information: No profiling information for SOQL operations. No profiling information for SOSL operations. No profiling information for DML operations. No profiling information for method invocations. ***Ending Page Log for /apex/TestActionPage?expose=12

It did not invoke the toggleItem function at all.

Does anyone know what could be the problem?

thanks,
Pi

Hi there,

 

I am having trouble getting the repeater below to recognize the fields of the subclass (Door).  Am I overlooking something, or is this not supported?  If so, are there any workarounds?  

 

Thanks a lot in advance for the feedback,

Pi

 

 

---------------------------

public class Door {
     public String DoorName = '';
     public String DoorID = '';
    
        public String getDoorName()
        {
            return DoorName;
        }
        public String getDoorID()
        {
            return DoorID;
        }    
}

public class Car {
    
     public String CarName = '';
     public List<Door> Doors = new List<Door>();
    
        public String getCarName()
        {
            return CarName;
        }
      
        public List<Door> getDoors()
        {
            return Doors;
        }           
   }

 

    public List<Car> getReturnedCars()
    {
        return this.rCars;
    }  
    

 

 

As you can see, the Car class has a list of Doors.  The following is the page code which throws the unknown property error:

 

    <apex:dataTable value="{!getReturnedCars}" var="c" id="theTable" rowClasses="odd,even"
                        styleClass="tableClass" cellspacing="1" cellpadding="1" border="0">
        <apex:column colspan="2" width="400">
            <apex:outputText value="{!c.CarName}"/>   <----- works fine
            <apex:repeat value="   {!c.Doors}" var="d" id="theRepeat">  
                <apex:outputText value="{!d.DoorName}" id="theValue"/><br/> <----- throws an Unknown property 'String.DoorName'
            </apex:repeat>            
        </apex:column>    
    </apex:dataTable>

getReturnedCars returns a List of Cars objects.    c.CarName is working fine.  c.Doors should have returned a list of Door objects.  But then it has trouble getting to the DoorName field of the Door object within the repeater.  Am I referencing the DoorName field correctly?  What is the right way to implement this?

Hi there,

 

What is the recommended way to send SMS messages from apex?  Are there any out of the box libaries available?  I have seen s-control examples which use google's sendtophone feature, but it has been discontinued.

 

thanks,

Pi

Hi there,

 

I have a trigger which works fine in Sandbox, but cannot be deployed to production because there doesn't seem to be a way to obtain the Id of a SObject before the actual Insert, kind of a chicken and the egg thing.  Here is what I have:

 

Trigger:

 

    Opportunity[] opps = Trigger.new;

        for (Opportunity o:opps)
        {
            OpportunityContactRole[] ocrs = [Select Id from OpportunityContactRole where OpportunityId=:o.Id];
            if (ocrs.size() == 0)
            {
                o.addError('A contact role does not exist.');
            }
        }

 

The above trigger prevents a save on an Opportunity if there's no OpportunityContactRole associated to the Opportunity.  It works like a charm.

 

The problem is that in order to test this trigger class, I need the ability to create an OpportunityContactRole before I can save the test Opportunity (otherwise, the system will not allow the test Opportunity to be saved because there's no OpportunityContactRole).  Here are the challenges:

 

- In order to create an OpportunityContactRole test object, I have to associate it to an Opportunity object via the OpportunityId field (or establish a relationship between this OpportunityContactRole record and the soon to be created Opportunity record), but this ID is not generated until I call insert on the test Opportunity object. 

- I cannot create the Opportunity first because the insert will fail for there's no OpportunityContactRole associated to the Opportunity.

- We cannot set a custom ID for an Opportunity object (not allowed to set Ids on any Sobjects).

 

The only thing I can think of is if there's a way to obtain a valid ID for an opportunity object before the insert call and use that to create the OpportunityContactRole first, and then call insert on the opportunity object.  But I don't think this can be done ....  How would you approach this problem?

 

thanks in advance for the feedback.

Pi

 

 

I am using the Force.com WSC connector for Java.

 

Is it possible to return a list of fields or field names from a QueryResult's SObject?  I only see getField (which requires that I hardcode the name of the field of interest).  I am looking for something like getFields which returns an array of field objects or field names, etc..

 

I could go through and parse the select field statement to determine these names based on the query the user enters.  I just want to check here to see if there's a way to identify the list of fields requested from the QueryResult object.  Any feedback is appreciated.

 

thanks

We are evaluating Email to Case (On Demand).   It looks like the way it works out of the box is when we forward emails from support@company.com to the SF routing address, because the FromAddress for all the forwards is set to support@company.com, then all cases created via Email to Case (On Demand) will automatically have the Contact field set to a contact record for support@company.com (instead of the actual customer contact account for the person who sent the original email to support@company.com).  

 

What is the recommended (best practice) way to tackle this without having to write something like an after Insert case trigger to update the Contact relationship and parsing the TextBody of the email from the EmailMessage object to determine the true "sender"'s email address?

 

thx!

 

Hi there,

 

We are trying to implement a new custom object to store product defects.  We have 1 requirement we are not sure if it requires customization.  The specific requirement is the following:

 

- The ability to relate product defects to each other (ie. records within the same object) by selecting existing defects in the system.

- A *single* related list (eg. "Related Defects") on the product defect layout to show all "linked" product defects, eg. if DefectA is linked to DefectB and DefectC, DefectA's related list will show B and C, DefectB's related list will show A and C, and so on.

 

Can this be done without customization?

 

thanks

Hi there,

 

I have the following test code which updates a field in a related object (CustomObject__r).  The CustomObject is related to Opportunity and the code below runs through successfully.

 

Opportunity o = [select CustomObject__r.Market__c,StatusMessage__c from Opportunity where Id='00600000008HFNLAA5'];
           o.CustomObject__r.Market__c = 'test';
           o.StatusMessage__c = 'test update';
           
            try
            {
                Database.SaveResult srs = Database.update(o);
                if (srs.isSuccess())
                {
                     // successful
                }
            } catch (Exception e) {
                    ApexPages.addMessages(e);
            }      

 

The above code does not return an exception and also is successful based on the return value of isSuccess().  The StatusMessage__c in the main object is successfully updated, but the CustomObject__r.Market__c field does not get updated even though the update transaction as a whole is deemed successful.  Any troubleshooting ideas, or if the above update is not possible (ie. have to fetch back and update CustomObject__c directly)?

 

thanks

I think I am overlooking something simple here, any help is appreciated.  Here is an isolated example (as you can see, the trigger doesn't actually do anything, it's trimmed down to just show the problem).   The testmethod runs fine with 100% coverage when testing against the sandbox environment.  

 

During deployment validation (when attempting to deploy to production), when the testmethod gets to the insert statement for the case, it goes into the trigger as expected (after insert), but it gives a "list has no rows" error in the trigger (when it attempts to query for the contact associated to the case).  But the contact is created at the beginning of the testMethod and associated to the case before the insert statement so I would expect that the validation process would find this contact because it is created and associated to the case as part of the testmethod.  Can anyone tell me why it cannot locate the contact during the deployment process?

 

thanks!

Pi

 

---------------

trigger testTrigger on Case (after insert) {

    for (Case c:Trigger.new)
    {
        Contact contact1 = [select AccountId from Contact where Id=:c.ContactId]; //caused by: System.QueryException: List has no rows for assignment to SObject
    }

}

 

 

    static testMethod void myUnitTest() {

        Test.startTest();
        Account a = new Account();
        a.Name='Test Account';
        a.Industry = 'Automotive';
        insert a;
        
        Contact contact1 = new Contact();
        contact1.FirstName = 'First';
        contact1.LastName = 'Last';
        contact1.AccountId = a.Id;
        insert contact1;        

         Case case1 = new Case();
         case1.ContactId=contact1.Id;
         case1.Subject='test Subject';
        insert case1;         
        
        system.assertEquals(a.Id,[select AccountId from Contact where Id=:case1.ContactId].AccountId);
        Test.stopTest();
    }

hi there,

 

I have a simple question.  I know how to throw errors from apex triggers by using the sObject.addErrors method.  This gets displayed on the UI as a red error message.   Is there a way to throw info level messages that show up as a non-critical message?  Or will I have to write something custom like set the info messages in a field from the trigger and display that field in a info message section on the UI?

 

thx,

Pi

SELECT Name, (SELECT lastname FROM Contacts WHERE CreatedBy.Alias = 'x') FROM Account

 

Take the above example, is there a way (in SOQL only) to only return Account rows where the child relationship subquery ((SELECT lastname FROM Contacts WHERE CreatedBy.Alias = 'x')) is not empty (ie. contains at least 1 child object row)?

 

thanks

Pi

There is a requirement that instead of generating more pdf files for all customer, can we combine all the files into a single PDF files or a zip file using Apex code

hi there,

 

I have spent many hours on this and can't figure out why Visualforce has trouble with YUI Panel renders when using repeater components.  Here is my isolated repro test case:

 

 

<apex:page controller="TestYUIC" tabStyle="Account" sidebar="false">

<apex:styleSheet value="http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/skin.css" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/container/container-min.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js" />
 
<script>

    YAHOO.namespace("force.com");

    YAHOO.force.com.showMe = function() {
        document.getElementById("myDialogPanel").style.display = "block";
        YAHOO.force.com.myDialog.show();
    }
   
    function passToShowMe(repeaterString)
    {
        passToController(repeaterString);   
        var elementID = "DialogHere" + repeaterString;
        YAHOO.force.com.myDialog.render(document.getElementById(elementID));
        YAHOO.force.com.showMe();
    }    

    YAHOO.force.com.hideMe = function() {
        YAHOO.force.com.myDialog.hide();
    }
 
    YAHOO.force.com.init = function() {
        document.body.className = document.body.className + " yui-skin-sam";
       
        YAHOO.force.com.myDialog = new YAHOO.widget.Panel(
            "myDialogPanel",  // The id of our dialog container
            {
                    width           :   50,    // You can play with this until it's right
                    visible         :   false,  // Should be invisible when rendered
                    draggable       :   true,   // Make the dialog draggable
                    close           :   false,  // Don't include a close title button
                    modal           :   false,   // Make it modal
                    fixedCenter     :   false,   // Keep centered if window is scrolled
                    zindex          :   40,     // Make sure it's on top of everything
                    constraintoviewport    :    true,           
            }
         );
    }
   
    YAHOO.util.Event.addListener(window, "load", YAHOO.force.com.init);
</script>

<apex:form id="MainForm">
<apex:repeat value="{!repeaterStrings}" var="s" id="StringRepeater">
        <input id="Button{!s}" type="button" class="btn"
                    onclick="passToShowMe('{!s}')"
                    value="{!s}" />
        <div id="DialogHere{!s}"></div>
        <apex:actionFunction name="passToController" action="{!DoSelect}" rerender="dialogPanel">
            <apex:param name="FruitSelection" value="" />
        </apex:actionFunction>            
</apex:repeat>   
</apex:form>

<apex:form >
<div id="myDialogPanel" style="display: none" >
     <apex:outputPanel id="dialogPanel" layout="block">
  <div class="hd">
    <apex:outputText value="{!Fruit}" />
  </div>
  <div class="bd">
        <div style="text-align: center;" >
          <apex:commandButton value="Close" immediate="true" oncomplete="YAHOO.force.com.hideMe();"/>
        </div>
  </div>
    </apex:outputPanel>
</div>                                  
</apex:form>

</apex:page>

 

 

public class TestYUIC {
   
public List<String> repeaterStrings = new List<String>();
public String Fruit {get; set;}

      public TestYUIC()
      {
          repeaterStrings.add('Apple');
          repeaterStrings.add('Strawberry');
          repeaterStrings.add('Banana');
          repeaterStrings.add('Mango');
      }
     
      public void DoSelect()
      {
          Fruit = Apexpages.currentPage().getParameters().get('FruitSelection');
         
      }     
     
      public List<String> getrepeaterStrings()
      {
          return repeaterStrings;
      }
}

 

 

Based on the view source of the page, the above code correctly generates a set of unique div tags intended for panel placements, eg.  DialogHereApple, DialogHereStrawberry, and so on.

 

        <input class="btn" id="ButtonApple" onclick="passToShowMe('Apple')" type="button" value="Apple" />
<div id="DialogHereApple"></div><script id="j_id0:MainForm:StringRepeater:0:j_id7" type="text/javascript">passToController=function(FruitSelection){A4J.AJAX.Submit('_viewRoot','j_id0:MainForm',null,{'similarityGroupingId':'j_id0:MainForm:StringRepeater:0:j_id7','parameters':{'j_id0:MainForm:StringRepeater:0:j_id7':'j_id0:MainForm:StringRepeater:0:j_id7','FruitSelection':FruitSelection||''} ,'actionUrl':'https://c.cs0.visual.force.com/apex/TestYUIP'} )};
</script>
        <input class="btn" id="ButtonStrawberry" onclick="passToShowMe('Strawberry')" type="button" value="Strawberry" />
<div id="DialogHereStrawberry"></div><script id="j_id0:MainForm:StringRepeater:1:j_id7" type="text/javascript">passToController=function(FruitSelection){A4J.AJAX.Submit('_viewRoot','j_id0:MainForm',null,{'similarityGroupingId':'j_id0:MainForm:StringRepeater:1:j_id7','parameters':{'j_id0:MainForm:StringRepeater:1:j_id7':'j_id0:MainForm:StringRepeater:1:j_id7','FruitSelection':FruitSelection||''} ,'actionUrl':'https://c.cs0.visual.force.com/apex/TestYUIP'} )};
</script>

 

The page simply displays 4 buttons on load.  I expect a dialog to render right after each button depending on the button I click on (because each button has an unique div tag after it for rendering). However, when clicking on the buttons, the panel always renders after the first button I click on ...

 

 

 

Say I click on the button for Mango first, the panel renders in the DialogHereMango div tag, but then if I click on the Apple button, the panel still renders in the DialogHereMango div tag.  If I put an alert tag after the line var elementID = "DialogHere" + repeaterString; in the passToShowMe function, it correctly shows the elementID passed on to the render method for each click.

 

Any YUI/VF experts out there who can help shed some light on why the YUI panel does not render in the targeted div tag when using apex:repeater component?

 

thanks,

Pi

Hi there,

 

I am kind of new to SSL so any help is greatly appreciated. 

 

I have a self-signed certificate generated within Salesforce.  According to the documentation, when making HTTPs callout to a 3rd party service, I have to deliver this SF signed cert to the 3rd party.  This part makes sense because the 3rd party needs the cert to decrypt data that is encrypted by the private key associated to the cert (which SF has). 

 

But how about the response from the 3rd party system back to Apex?  It seems like the 3rd party system will need (in addition to the signed cert) the private key associated to the self-signed cert generated by SF to encrypt the data back to Apex?  Is this correct? If so, will I need the private key SF used to generate that specific cert in the first place?

 

thanks,

Pi

Hi there,

 

Sorry, I am not sure if URL state is the right terminology here, but I will try to explain what I am trying to do here :)


1.  The user brings up the VF page (eg. MyPage) with a parameter in the URL: eg. http://site/apex/Page?e=12
2.  Based on the value of e, the controller of the VF page (eg. MyController) runs some logic and populates the VF page as part of its MyController() method.
3.  On MyPage, there is a set of output links (or ahrefs) with different values for e, eg.
http://site/apex/Page?e=2
http://site/apex/Page?e=3
http://site/apex/Page?e=4
4.  When the user clicks on these links, say, http://site/apex/Page?e=2, I would like to take the current e parameter ie. e=12 and append it to the e parameter that is selected and redirect the page back to itself as the URL: http://site/apex/Page?e=2+12, so that new data will be populated on MyPage based on now 2 different parameter values.  And then if the user clicks on http://site/apex/Page?e=3, I would like to take 3 and append it to the current url "state", and redirect back to MyPage with e=2+12+3, and so on, etc..

 

I figure I have to store the "state" of the url somewhere.  I am thinking I could have an onClick event on each of the separate links in Step 3, which updates a List or Map that stores the current state of the URL (ie. the running total of e's).  So I created a public List variable to store the running list of e's selected in MyController.  In my onClick method in the controller, I perform a PageReference in an attempt to modify the URL ... but the problem here is that if I use a PageReference.setRedirect back to the same page with the right e string (eg. 2+12), the URL of the page (and getParameters()) shows only e=2 (the last selected one), which means that the code in Step 2 to populate the page will keep painting it with data related to the last selected e (ie. 2)

 

How would you tackle this use case (storing url state)?  Any feedback is appreciated.

Pi

Message Edited by Iceman123 on 01-15-2010 09:52 AM

Given the same VF page and Apex controller using a very simple example invoking the actionFunction, I am seeing that it works only in IE and not in Firefox.


The controller code:

public class TestAction {

public String ExposeID { get; set; }

public PageReference toggleItem()
{
ExposeID = Apexpages.currentPage().getParameters().get('firstParam');
system.debug('~~~~~~~~~ IN TOGGLE ITEM');

return null;
}


}

The page code:

<apex:page controller="TestAction" tabStyle="Account" sidebar="false">
<apex:form >

<a href="/apex/TestActionPage?expose=12" onclick="toggleItemJS('12');">Item 12</a>

<apex:actionFunction action="{!toggleItem}" name="toggleItemJS" rerender="showstate" >
<apex:param name="firstParam" assignTo="{!ExposeID}" value="" />
</apex:actionFunction>

<p><apex:outputText value="Item Exposed: {!ExposeID}" id="showstate" /></p>
</apex:form>

</apex:page>



When using IE as the client browser, the debug window shows:

 

------------------------------------------------------------------------

 

10:05:37 DEBUG -
***Begining Page Log for /apex/TestActionPage
Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

No profiling information for method invocations.


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:37 DEBUG -
***Begining Page Log for /apex/TestActionPage
Cumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

No profiling information for method invocations.


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:38 DEBUG -
***Begining Page Log for /apex/TestActionPage
20100107180537.295:Class.TestAction.toggleItem: line 8, column 8: ~~~~~~~~~ IN TOGGLE ITEM
20100107180537.295:External entry point: returning NULL from method public System.PageReference toggleItem() in 0 ms

Element j_id3 called method {!toggleItem} returned type PageReference: noneCumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

1 most expensive method invocations:
Class.TestAction: line 5, column 23: public System.PageReference toggleItem(): executed 1 time in 0 ms


***Ending Page Log for /apex/TestActionPage?expose=12
10:05:38 DEBUG -
***Begining Page Log for /apex/TestActionPage
20100107180537.295:Class.TestAction.toggleItem: line 8, column 8: ~~~~~~~~~ IN TOGGLE ITEM
20100107180537.295:External entry point: returning NULL from method public System.PageReference toggleItem() in 0 ms

Element j_id3 called method {!toggleItem} returned type PageReference: noneCumulative profiling information:

No profiling information for SOQL operations.

No profiling information for SOSL operations.

No profiling information for DML operations.

1 most expensive method invocations:
Class.TestAction: line 5, column 23: public System.PageReference toggleItem(): executed 1 time in 0 ms


***Ending Page Log for /apex/TestActionPage?expose=12


------------------------------------------------------------------------
As you can see, it called the toggleItem function correctly.

But when I use a Firefox browser (tried 2.0 , 3.0 and 3.5), it only writes:

10:04:50 DEBUG - ***Begining Page Log for /apex/TestActionPage Cumulative profiling information: No profiling information for SOQL operations. No profiling information for SOSL operations. No profiling information for DML operations. No profiling information for method invocations. ***Ending Page Log for /apex/TestActionPage?expose=12

It did not invoke the toggleItem function at all.

Does anyone know what could be the problem?

thanks,
Pi

Hi there,

 

I am having trouble getting the repeater below to recognize the fields of the subclass (Door).  Am I overlooking something, or is this not supported?  If so, are there any workarounds?  

 

Thanks a lot in advance for the feedback,

Pi

 

 

---------------------------

public class Door {
     public String DoorName = '';
     public String DoorID = '';
    
        public String getDoorName()
        {
            return DoorName;
        }
        public String getDoorID()
        {
            return DoorID;
        }    
}

public class Car {
    
     public String CarName = '';
     public List<Door> Doors = new List<Door>();
    
        public String getCarName()
        {
            return CarName;
        }
      
        public List<Door> getDoors()
        {
            return Doors;
        }           
   }

 

    public List<Car> getReturnedCars()
    {
        return this.rCars;
    }  
    

 

 

As you can see, the Car class has a list of Doors.  The following is the page code which throws the unknown property error:

 

    <apex:dataTable value="{!getReturnedCars}" var="c" id="theTable" rowClasses="odd,even"
                        styleClass="tableClass" cellspacing="1" cellpadding="1" border="0">
        <apex:column colspan="2" width="400">
            <apex:outputText value="{!c.CarName}"/>   <----- works fine
            <apex:repeat value="   {!c.Doors}" var="d" id="theRepeat">  
                <apex:outputText value="{!d.DoorName}" id="theValue"/><br/> <----- throws an Unknown property 'String.DoorName'
            </apex:repeat>            
        </apex:column>    
    </apex:dataTable>

getReturnedCars returns a List of Cars objects.    c.CarName is working fine.  c.Doors should have returned a list of Door objects.  But then it has trouble getting to the DoorName field of the Door object within the repeater.  Am I referencing the DoorName field correctly?  What is the right way to implement this?

Hi there,

 

What is the recommended way to send SMS messages from apex?  Are there any out of the box libaries available?  I have seen s-control examples which use google's sendtophone feature, but it has been discontinued.

 

thanks,

Pi