• JmBessonart
  • NEWBIE
  • 105 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 24
    Replies

Hi,

 

I know this has been posted before, but I have't found a solution to my question.

 

I need to able to get the server url via apex code. For example: https://tapp0.salesforce.com/

 

Is there a call that does that already and if not are there any work-arounds?

 

Thank you very much.

  • October 20, 2009
  • Like
  • 0

How can i convert the firstname and Lastname first character to uppercase?

Sorry I am not a Java coder so am not sure how this is done.

Hello,

 

I'm using the XMLDom class to parse some XML. I'm trying to set a variable to a list of tag names that I can loop through later. What is the correct return type I should set 'names' in the following code to?

 

 

names = responseXML.getElementsByTagName('names');

 

I've tried setting it to List<String> but I get the following error:

 

  Error: Compile Error: Illegal assignment from LIST:XMLDom.Element to LIST:String

 

Thanks,

Dan

  • June 10, 2009
  • Like
  • 0

Hi,

I have a test class that create a new Opportunity to work with. The problem is that some customers have their own validation rules in some of the Opportunity object, and cause the insert fail.

 

 

Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today());
insert newOppty;

 

 There is a way to know if there are any validation rule on the opportunity fields before the insert and create a valid Opportunity?? What is the best practice in this case?, because I can't what the users can have differents validations depend of each Org. 

 

Thanks

J.

Hi,

I have a test class that create a new Opportunity to work with. The problem is that some customers have their own validation rules in some of the Opportunity object, and cause the insert fail.

 

 

Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today()); insert newOppty;

 

 There is a way to know if there are any validation rule on the opportunity fields before the insert and create a valid Opportunity?? What is the best practice in this case?, because I can't what the users can have differents validations depend of each Org. 

 

Thanks

J.

Hi, I have activated translation workbench in my org and set some of the picklist values translations.

Then i've created a package and added the "Language Transaltion". I try to install it in other org and the translation workbench is installed automatically with the package, but the translation of the picklist values are gone...

I'm missing something?? Any suggestions??

 

Thanks in advance

 

Juan. 

Hi,

  I have a google map implement into my application. This monday i've entered to the page that have the google map include, but it show me a empty alert and the map don't show up!!.

 

I figure out that if you comment the "if (GBrowserIsCompatible()) {" check, the map show up, but the empty alert stilll showing...

 

This can be cause by the new salesforce release??

 

Any idea that what cause the problem??

 

Thanks 

J.

Hi, i'm looking for a way to resize images and save them like attachments in 3 different sizes.

I was searching and couldn't find any way to do this.... Is it possible??

 

Thanks

J.

Hi,

 

I want to abort the Ajax request cause by clicking a commandLink.

 

I was thinking in something like this....

 

 

<script> function startRequest () { alert('startRequest'); } function endRequest () { alert('endRequest'); } function abortRequest () { var currentAjaxPost = ......; currentAjaxPost.abort(); } </scrip> <apex:form> <apex:outputpanel id="fooPanel"></apex:outputpanel> <apex:commandLink action="{!foo}" onclick="startRequest();" oncomplete="endRequest();" rerender="fooPanel"/> <a href="javascript:;" onclick="abortRequest();">ABORT</a> </apex:form>

 

After clicking on comandLink, while the action is being executed, if I click on ABORT link, I want the ajax request to be cancelled( preventing the endRequest(); function to be called ) .

 

 

 Any idea??

 

Thanks

J.

 

 

Hi, i have a problem using a commandLink with the rerender attribute and a google map in the same page (the google map ISN'T into the component that i'm rerendering....)

 

This is  a simple example of my code:

 

 

This is the visualforce page :

 

<script>
window.onload = initializeGoogleMap;

function initializeGoogleMap() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("GoogleMapHolder"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
</script>
<apex:outputpanel id="aux"></apex:outputpanel>
<apex:form >
<apex:commandLink action="{!refresh}" rerender="aux" value="Refresh Aux"/>
</apex:form>
<div id="GoogleMapHolder" style="width: 315px; height: 330px"></div>

 

And the controller:

 

 

public void refresh () {}

 

When the action finished, the page turn all white and loading, and never stop...

 

Any idea of what cause this behavior???

 

Thanks

 

J. 

Hi, i have a problem using a commandLink with the rerender attribute and a google map in the same page (the google map ISN'T into the component that i'm rerendering....)

 

This is  a simple example of my code:

 

 

This is the visualforce page :

 

<script>
window.onload = initializeGoogleMap;

function initializeGoogleMap() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("GoogleMapHolder"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
</script>
<apex:outputpanel id="aux"></apex:outputpanel>
<apex:form >
<apex:commandLink action="{!refresh}" rerender="aux" value="Refresh Aux"/>
</apex:form>
<div id="GoogleMapHolder" style="width: 315px; height: 330px"></div>

 

And the controller:

 

 

public void refresh () {}

 

When the action finished, the page turn all white and loading, and never stop...

 

Any idea of what cause this behavior???

 

Thanks

 

J. 

 

 

 

 

Hi, i want to post a html FORM with remoteFunction (obtein the same result). Because i don't want that the page redirect to the action page (happend if i use the normal FORM), only i need to know the url of the result page. I think remoteFunction is the solution, because i can use onSuccess : function(response, request) {  }.

 

I have something like this:

 

 

<form action="http://........../foo.aspx" method="post"> <input type="hidden" name="var1" value="value1"> <input type="hidden" name="var2" value="value2"> <input type="submit" value="submit"/> </form>

 

 

 

 

 And i want to "translate" into some like this:

 

 

var actionFormUrl = 'https://................../foo.aspx'; var contentString = 'var1=value1&var2=value2'; var contentLength = String(contentString.length); sforce.connection.remoteFunction( { url :actionFormUrl, requestHeaders: {"Content-Type":"application/x-www-form-urlencoded", "Content-Length": contentLength, "SOAPAction": "\"\""}, method: "POST", mimeType: "text/xml", requestData: contentString, cache : true, async: false, onFailure : function fail(response, request) { alert('Error'); }, onSuccess : function(response, request) { alert('Success'); } });

 

 My idea is on the onSuccess event get the url of the response (http://................./anotherPage.aspx?...............................................................), but the remoteFunction faild, the error is this:

 

 

<html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="https://......................./generic.aspx?..................................................." >here</a>.</h2> </body></html>

 

Any idea???

 

Thanks

Juan.

 

 

 

 

Hi,

 

 I'm triying to insert a new Lead and throw me this error message:

 

System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, invalid parameter value

 

 I have a commandButton that call the method like this:

 

 

<apex:commandButton value="ADD TO LEADS" action="{!addLead}" />

 

And the method:

 

 

 

public PageReference addLead () {

Lead newLead = new Lead(Email='foo@foo.com', FirstName='Foo Name', Company='Foo Company', LastName='Foo Last Name');
insert newLead;

PageReference pageRef = new PageReference('/'+ Lead.sObjectType.getDescribe().getKeyPrefix());
pageRef.setRedirect(true);
return pageRef;
}

 

 

 

 

 

Any idea??

 

Thanks

J.

 

 

Hi,

I have a test class that create a new Opportunity to work with. The problem is that some customers have their own validation rules in some of the Opportunity object, and cause the insert fail.

 

 

Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today());
insert newOppty;

 

 There is a way to know if there are any validation rule on the opportunity fields before the insert and create a valid Opportunity?? What is the best practice in this case?, because I can't what the users can have differents validations depend of each Org. 

 

Thanks

J.

I'm using Safari in a sandbox org to debug a VF page, and the System Log window does not show any logs.  I'm not sure if this is related to sandbox or not.  I can get System Log to work in Firefox, *if* I go to the VF page first (which has a different domain, c.cs2..., thus cross domain security prevents system log from getting updates I assume) and then launch the System Log.  This workaround doesn't work in Safari though.  

 

The System Log has been erratic for me since day 1, and I'd love to know if there's some fix or I'm doing something wrong.  

 

Jeremy 

Hi,

 

I know this has been posted before, but I have't found a solution to my question.

 

I need to able to get the server url via apex code. For example: https://tapp0.salesforce.com/

 

Is there a call that does that already and if not are there any work-arounds?

 

Thank you very much.

  • October 20, 2009
  • Like
  • 0


My initial code get error when sending more queries as "System.Exception: Too many SOQL queries: 101"
So I rearrange code avoid query within loop.But afterthat it doesn't get results.
Here I use Database.query(sql) for getting describe objects.

Basically I want to get result of Database.query() to List object


Initial code

 

        String oppSOQL = 'SELECT ';
        for (String fieldName : oppFieldsMap.keySet()) {
          oppSOQL += fieldName + ',';
        }
        for (Integer i = 0; i < arrIds.size(); i++) {
          String id = arrIds[i];
          String fullSOQL = '';
          String SOQLEnd = ' FROM Opportunity WHERE Id = \'' + id + '\'';
          if (customObjectDescribedQuery != null && customObjectDescribedQuery != '') {
            fullSOQL = oppSOQL + '(' + customObjectDescribedQuery + ')' +  SOQLEnd;
          } else {
            fullSOQL = oppSOQL.substring(0, oppSOQL.length() - 1)  +  SOQLEnd;
          }
          sObject sObj = Database.query(fullSOQL);
          o = (Opportunity)sObj;
          opportunityList.add(o);
          subTotal += o.EM_TotalBeforeSalesDiscount__c;
        }
        for (Opportunity opp : opportunityList) {
          oppObj = new OpportunityWrapper(opp);
          selectedOpportunityList.add(oppObj);
        }

 

Rearrange Code       

 

        String oppSOQL = 'SELECT ';
        for (String fieldName : oppFieldsMap.keySet()) {
          oppSOQL += fieldName + ',';
        }
        List<Id> oppIds = new List<Id>{};
        for (Integer k = 0; k < arrIds.size(); k++) {
          oppIds.add(arrIds[k]);
        }
        String fullSOQL = '';
        String SOQLEnd = ' FROM Opportunity WHERE Id IN: ' + oppIds;
        if (customObjectDescribedQuery != null && customObjectDescribedQuery != '') {
          fullSOQL = oppSOQL + '(' + customObjectDescribedQuery + ')' +  SOQLEnd;
        } else {
          fullSOQL = oppSOQL.substring(0, oppSOQL.length() - 1)  +  SOQLEnd;
        }
         List<Opportunity> oppList = Database.query(fullSOQL);      //new List<Opportunity>(Database.query(fullSOQL));         
        for(Opportunity o :oppList ){
          opportunityList.add(o);
          subTotal += o.EM_TotalBeforeSalesDiscount__c;
       }
       
        for (Opportunity opp : opportunityList) {
          oppObj = new OpportunityWrapper(opp);
          selectedOpportunityList.add(oppObj);
        }

Message Edited by kumara100 on 10-20-2009 04:33 AM

Hi,

 

I am including a simple VF page (for now just the default 'Congratulations'example) in the left hand navigation section of the homepage (so it will be loaded each time a new page is navigated to).

 

To achieve this I have used the suggested IFRAME option:

 

<iframe src="/apex/test2" width="10" frameborder="0" height="10"></iframe>

 

Unfortunately I keep getting the IE security warning that this page contains unsecure items, do I wish to load it.In Firefox it works fine.

 

If I navigate manually to the page there is no security issue (as you would expect as it is the very simple VF default page). So there must be something wrong with the way I'm using the iframe...can anyone immediately point out where I am being stupid?

 

Thank you!

 

 

Message Edited by mattpick1 on 10-20-2009 03:46 AM
How to Display Calendar Object on Custom home page  or  visual force pages
  • October 20, 2009
  • Like
  • 0

I could use some help here. You'll notice in the code below that I have hardcoded int the Contact rt query the Id. I want the query to be run with a dynamic Id. I have tried everything especially =:ContactId or even the long version =:o.ContactId__c. The update that sets o.Registered_Member__c = ContactId is working so I know the variable is being populated. I am new to Eclipse and it won't let me do the above variable queries.

 

The Trigger looks like this:

 

trigger UpdateMember on Opportunity (before insert) { for(Opportunity o:Trigger.new)

{

String ContactId=o.ContactId__c;

String Member=o.Registered_Member__c;

String RegisteredId=o.Registered_UserId__c;

if(ContactId!='' && o.Registered_Member__c==null)

{

o.Registered_Member__c = ContactId;

Contact rt = [select Id, FirstName from Contact where Id='0038000000lqpyL' limit 1];

String FirstName=rt.FirstName;

o.Registered_Member_First__c = FirstName;

}

if(RegisteredId!='' && o.Registering_Contact__c==null)

{

o.Registering_Contact__c = RegisteredId;

}

}

}

 

Thanks.

Hi to all.,
I have two objects.,
In one object (Contact details) the fields are  firstname ,lastname and Owner.
the second object(View)
I wrote the trigger on View object on after insert.

contact_Details con = [select firstname__c,Lastname__c,owner]

trigger trg_view on View__c (after insert)
{
    for(View__c viewobj: Trigger.New)
    {
  contact_Details__c con = [select id,firstname__c,Lastname__c,owner from contact_Details__c where owner =: CreatedById ];
  viewobj.condaetails__c = con.id;
    }

But this trigger show the error on OWNER FIeld.
then How to compare it and how to write the soql query with select Owner field statement?????

 

Thanks,
Krishna.

Hi All,

 

I am trying to query 10000 records and using a for loop o fetch them all. I know we can get these records in a list but can we get them in a map?

 

When i try :

 

 

for(Map<Id,Account> aMap : new Map<Id,Account>([Select Id,Name from Account])){}

 

 I am getting this error: Loop must iterate over a collection type: MAP:Id,SOBJECT:Account
 
Please advise. 

 

  • October 19, 2009
  • Like
  • 0

I need to populate a picklist with all the users under a particular profile.

 

Need Help.

How can i convert the firstname and Lastname first character to uppercase?

Sorry I am not a Java coder so am not sure how this is done.

Hi,

  I have a google map implement into my application. This monday i've entered to the page that have the google map include, but it show me a empty alert and the map don't show up!!.

 

I figure out that if you comment the "if (GBrowserIsCompatible()) {" check, the map show up, but the empty alert stilll showing...

 

This can be cause by the new salesforce release??

 

Any idea that what cause the problem??

 

Thanks 

J.

Hi,

I am developing a Salesforce app. And in some place I need go to an external page, get an activation key than come back to the Salesforce page.

 

But after redirecting my page along with ActivationKey parameter like this: "http:///blahblahblah.salesforce.com/na4ggg?ActivationKey=3043049404040943 salesforce needs me to login again and i type my password. Then i am forwarded to the page that  requested without ActivationKey. I think because of the login process, it is clearing the ActivationKey parameter.

 

I want to get the parameter from that page and put it into a textbox inside my custom page based on above scenario.

 

Is there a way to do this?

 

Thanks,

Umut

 

Hello,

 

I'm using the XMLDom class to parse some XML. I'm trying to set a variable to a list of tag names that I can loop through later. What is the correct return type I should set 'names' in the following code to?

 

 

names = responseXML.getElementsByTagName('names');

 

I've tried setting it to List<String> but I get the following error:

 

  Error: Compile Error: Illegal assignment from LIST:XMLDom.Element to LIST:String

 

Thanks,

Dan

  • June 10, 2009
  • Like
  • 0

Hi,

 

I want to abort the Ajax request cause by clicking a commandLink.

 

I was thinking in something like this....

 

 

<script> function startRequest () { alert('startRequest'); } function endRequest () { alert('endRequest'); } function abortRequest () { var currentAjaxPost = ......; currentAjaxPost.abort(); } </scrip> <apex:form> <apex:outputpanel id="fooPanel"></apex:outputpanel> <apex:commandLink action="{!foo}" onclick="startRequest();" oncomplete="endRequest();" rerender="fooPanel"/> <a href="javascript:;" onclick="abortRequest();">ABORT</a> </apex:form>

 

After clicking on comandLink, while the action is being executed, if I click on ABORT link, I want the ajax request to be cancelled( preventing the endRequest(); function to be called ) .

 

 

 Any idea??

 

Thanks

J.

 

 

Hi, i have a problem using a commandLink with the rerender attribute and a google map in the same page (the google map ISN'T into the component that i'm rerendering....)

 

This is  a simple example of my code:

 

 

This is the visualforce page :

 

<script>
window.onload = initializeGoogleMap;

function initializeGoogleMap() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("GoogleMapHolder"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
</script>
<apex:outputpanel id="aux"></apex:outputpanel>
<apex:form >
<apex:commandLink action="{!refresh}" rerender="aux" value="Refresh Aux"/>
</apex:form>
<div id="GoogleMapHolder" style="width: 315px; height: 330px"></div>

 

And the controller:

 

 

public void refresh () {}

 

When the action finished, the page turn all white and loading, and never stop...

 

Any idea of what cause this behavior???

 

Thanks

 

J.