• ssfdc
  • NEWBIE
  • -1 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 11
    Replies
I need to set a param once a user has changed the value of an inputText field so it will be sent once the user clicks the commandButton, I can't figure this one out and am reultant to scrap my design for JS remoting,

Use: Case

A list of differect products, a user can select a quantity then hit Add, the product Id and quanitity should be passed, the Id is set correctly as this is set at run time but how to set soemthing and bind it to command button once the page is loaded?

    <apex:repeat value="{!prodList}" var="p">
      {!p.Name}

      <apex:inputText value="{!quant}"/>
      <apex:commandButton action="{!addItem}" value="Add">
       <apex:param name="id" assignTo="{!prodId}" value="{!p.Id}"/>
      </apex:commandButton>

    </apex:repeat>

  • April 25, 2014
  • Like
  • 0
I have two Salesforce instances, A & B, and I have created a simple webservice in instance A which when calls takes in a string and updates a record, I generated the WSDL from this class and copied the endpoint, In Org B I then used this endpoint in the the outbound message and passed in some Params, I'm finding it hard to get docuementation on this, do I need to import the generated WSDL into Org B, how to do I find the correct endpoint then?, would appreciate some pointers here im new to webservices.
  • March 18, 2014
  • Like
  • 0
I have a custom Getter and Setter in my Code, this populates a <apex:inputTextArea value="{!emailContent}"/>, Anytime I call an action from my command button the order of execution is, Get, Set, Get, the problem here is that the Set method with the new content is always being overwritten, Any help would bre great I'm sure its something I'm overlooking from lack of custom Get and Set implementations.

Thanks.

<apex:form>
   <apex:inputTextArea styleClass="ckeditor" richtext="false" value="{!emailContent}"/>
   <apex:commandButton action="{!sendEmail}"  value="Send"/>
</apex:form>

public String emailContent {
        get {
            System.debug('GETTER');
           
            // Add some changes to emailContent
            return emailContent;  
        }
        set{
            System.debug('SETTER');
            emailContent = value;
        }   
    }
  • February 12, 2014
  • Like
  • 0

Hi I'm stuck when it comes to gettting to 75% test coverage, the problem is testing a method that makes a SOAP request, 

 

I have tried to implment "HttpCalloutMock" without success an am getting the following error =

 

"System.XmlException: only whitespace content allowed before start tag and not [ (position: START_DOCUMENT seen [... @1:1)"

 

Tutorial I followed:

http://blogs.developerforce.com/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html

 

My classes that simply send a SOAP request to check if Login credentials are correct, Any help would be great.

 

public HttpResponse verify(){

System.debug('Username: '+username+' Password: '+password+' Domain: '+login_domain);
HttpRequest request = new HttpRequest();
Http h = new Http();

request.setEndpoint('https://' + login_domain + '.salesforce.com/services/Soap/u/29.0');
request.setMethod('POST');
request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
request.setHeader('SOAPAction', '""');
request.setBody(buildSoap(username,password));

HttpResponse res = h.send(request);
final Boolean verified = res.getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;

/*
final Boolean verified = (new Http()).send(request).getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;
*/

if(verified) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Correct Credentials!'));
}
else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Incorrect Credentials!'));
}
return res;
}

public String buildSoap(String username, String password){
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');
w.writeNamespace('', 'urn:partner.soap.sforce.com');
w.writeStartElement('', 'username', 'urn:partner.soap.sforce.com');
w.writeCharacters(username);
w.writeEndElement();
w.writeStartElement('', 'password', 'urn:partner.soap.sforce.com');
w.writeCharacters(password);
w.writeEndElement();
w.writeEndElement();

String xmlOutput =
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>'
+ w.getXmlString()
+ '</Body></Envelope>';
w.close();
return xmlOutput;
}

 

 

  • December 04, 2013
  • Like
  • 0

I'm stumped over this one, I have successfully gnerated a PDF and attached it to a record as an attachment before, this application is slightly different but whatever I try the pdf seems corupted when i try and view and wont load.

 

Some code bellow:

 

public class theController {


   public PageReference savePdf() {
   //Save pdf
   String theURL = 'mySalesforceInstance/apex/pdfPage';
   PageReference pdf = new PageReference(theURL);
   Attachment attach = new Attachment();

   Blob body;

   try {

   / / returns the output of the page as a PDF
   body = pdf.getContent();

   // need to pass unit test -- current bug
   } catch (VisualforceException e) {
   body = Blob.valueOf('Some Text');
}

attach.Body = body;
// add the user entered name
attach.Name = 'pdfName.pdf';
attach.IsPrivate = false;
// attach the pdf to the account
//attach.ParentId = loggedInUser.contactId;

attach.ParentId = '00130000013epqx';

insert attach;

return null;
}

}

 

I am rendering "theUrl" page as a pdf as I did before, but when the pdf is Attached to my record i cannot open it,

I saved this as .html file to view the contents and I get the following:

 

<script>
if (window.location.replace){
window.location.replace('https://login.salesforce.com/?ec=302&startURL=%2Fapex%2FpdfPage');
} else {;
window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2Fapex%2FpdfPage';
}
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

 

 


</head>


</html>

 

<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->

 

 

Can anyone confirm that I'm not going mad as I built a similar appication before, has something changed??

 

I have triple checked my code, "theUrl" is correct etc.

 

Thanks.

 

 

 

 

 

 

 

 

  • February 22, 2013
  • Like
  • 0

Maybe someone can can help me out with this logic to access variables from outside of a remote Method

 

Say I have my controller as follows Sudo code,

 

global with sharing class myController {

 

   public Map<String, String> myMap {get; set;}

 

   public myController() {

      Populate myMap with values

   }

 

   @RemoteAction

   global Static String returnStrValue(String keyStr) {

   

      String value = myMap.get(keyStr);

      return value;

   }

 

}

 

 

// NOW on my VF page

 

I would call upon my javaremote method to return a map value when a given key is supplied which i have in my javascript

The problem that im having and i know is that the variables created in my controller are not accesible from my remote method, im thinking maybe querying the MAP in my VF and assigning to a JS varaible then passing it back into my remote method so my remote method would look like this.

 

I havent got this way working yet as i dont think the MAP assisngs correctly to the JS variable, is there a better way to do this?  Thanks

 

@RemoteAction

   global Static String returnStrValue(String keyStr, Map<String, String>) {

   

      String value = myMap.get(keyStr);

      return value;

   }

 

}

 

 

 

 

 

  • February 09, 2013
  • Like
  • 0

Hi,

     I'm wondering if anyone knows if there's a way to supply a String[] as a list of strings as a Param into a component,

 

Take this for an example:

VF page

<c:myComp dataPanel="STRING [] I WANT TO SUPPLY" />

 

COMPONENT

<apex:attribute name="dataPanel" description="String[]" type="String[]" required="false"/>

 

So far the only way I can supply a String[] is to create one in a controller and assisng it to dataPanel={!strArrayInController}

 

I find this messy if someone is using this compoent and only need supply a few strings in say Comma seperated format I would have imagined somehting like this exists:

 

<c:myComp dataPanel="new String[] {'one','two','three'}" />

 

 

Any idea's?

 

Thanks

 

  • January 28, 2013
  • Like
  • 0
I need to set a param once a user has changed the value of an inputText field so it will be sent once the user clicks the commandButton, I can't figure this one out and am reultant to scrap my design for JS remoting,

Use: Case

A list of differect products, a user can select a quantity then hit Add, the product Id and quanitity should be passed, the Id is set correctly as this is set at run time but how to set soemthing and bind it to command button once the page is loaded?

    <apex:repeat value="{!prodList}" var="p">
      {!p.Name}

      <apex:inputText value="{!quant}"/>
      <apex:commandButton action="{!addItem}" value="Add">
       <apex:param name="id" assignTo="{!prodId}" value="{!p.Id}"/>
      </apex:commandButton>

    </apex:repeat>

  • April 25, 2014
  • Like
  • 0
I have a custom Getter and Setter in my Code, this populates a <apex:inputTextArea value="{!emailContent}"/>, Anytime I call an action from my command button the order of execution is, Get, Set, Get, the problem here is that the Set method with the new content is always being overwritten, Any help would bre great I'm sure its something I'm overlooking from lack of custom Get and Set implementations.

Thanks.

<apex:form>
   <apex:inputTextArea styleClass="ckeditor" richtext="false" value="{!emailContent}"/>
   <apex:commandButton action="{!sendEmail}"  value="Send"/>
</apex:form>

public String emailContent {
        get {
            System.debug('GETTER');
           
            // Add some changes to emailContent
            return emailContent;  
        }
        set{
            System.debug('SETTER');
            emailContent = value;
        }   
    }
  • February 12, 2014
  • Like
  • 0
Hi All,

I am new to Salesforce.

We have this following requirement.

We have four fields in a custom object (F1,F2,F3,F4)

If F1's value is set to "Start", then F2 should hold that current time in GMT.

And when the F1's value is changed from "Start", then F3 should store that changed time in GMT.

Also F4 should now display the (F3-F2) in days (Lets say F2 is 10:00 AM and F3 is 11:00 AM..then F4 should store/display as 0.0417)

Is it possible to implement this without using Apex ?

Hi I'm stuck when it comes to gettting to 75% test coverage, the problem is testing a method that makes a SOAP request, 

 

I have tried to implment "HttpCalloutMock" without success an am getting the following error =

 

"System.XmlException: only whitespace content allowed before start tag and not [ (position: START_DOCUMENT seen [... @1:1)"

 

Tutorial I followed:

http://blogs.developerforce.com/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html

 

My classes that simply send a SOAP request to check if Login credentials are correct, Any help would be great.

 

public HttpResponse verify(){

System.debug('Username: '+username+' Password: '+password+' Domain: '+login_domain);
HttpRequest request = new HttpRequest();
Http h = new Http();

request.setEndpoint('https://' + login_domain + '.salesforce.com/services/Soap/u/29.0');
request.setMethod('POST');
request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
request.setHeader('SOAPAction', '""');
request.setBody(buildSoap(username,password));

HttpResponse res = h.send(request);
final Boolean verified = res.getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;

/*
final Boolean verified = (new Http()).send(request).getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;
*/

if(verified) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Correct Credentials!'));
}
else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Incorrect Credentials!'));
}
return res;
}

public String buildSoap(String username, String password){
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');
w.writeNamespace('', 'urn:partner.soap.sforce.com');
w.writeStartElement('', 'username', 'urn:partner.soap.sforce.com');
w.writeCharacters(username);
w.writeEndElement();
w.writeStartElement('', 'password', 'urn:partner.soap.sforce.com');
w.writeCharacters(password);
w.writeEndElement();
w.writeEndElement();

String xmlOutput =
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>'
+ w.getXmlString()
+ '</Body></Envelope>';
w.close();
return xmlOutput;
}

 

 

  • December 04, 2013
  • Like
  • 0

Hello all,

 

Can anyone let me know what is making this simple trigger not to firing?

 

trigger DeleteContact on Contact (before delete){
     for(Contact c : Trigger.old){ 
     
       String profileId = UserInfo.getProfileId();
      
       if(c.AccountId!=null && (profileId!='00e11000000Df7mAAC') && (profileId!='00e11000000Df8aAAC') && (profileId!='00eb0000000rNRWAA2')){
                c.addError('You don\'t have sufficient rights to delete this record!');
                
                }
        }
 }

 Thanks in advanced!!

I'm stumped over this one, I have successfully gnerated a PDF and attached it to a record as an attachment before, this application is slightly different but whatever I try the pdf seems corupted when i try and view and wont load.

 

Some code bellow:

 

public class theController {


   public PageReference savePdf() {
   //Save pdf
   String theURL = 'mySalesforceInstance/apex/pdfPage';
   PageReference pdf = new PageReference(theURL);
   Attachment attach = new Attachment();

   Blob body;

   try {

   / / returns the output of the page as a PDF
   body = pdf.getContent();

   // need to pass unit test -- current bug
   } catch (VisualforceException e) {
   body = Blob.valueOf('Some Text');
}

attach.Body = body;
// add the user entered name
attach.Name = 'pdfName.pdf';
attach.IsPrivate = false;
// attach the pdf to the account
//attach.ParentId = loggedInUser.contactId;

attach.ParentId = '00130000013epqx';

insert attach;

return null;
}

}

 

I am rendering "theUrl" page as a pdf as I did before, but when the pdf is Attached to my record i cannot open it,

I saved this as .html file to view the contents and I get the following:

 

<script>
if (window.location.replace){
window.location.replace('https://login.salesforce.com/?ec=302&startURL=%2Fapex%2FpdfPage');
} else {;
window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2Fapex%2FpdfPage';
}
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

 

 


</head>


</html>

 

<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->

 

 

Can anyone confirm that I'm not going mad as I built a similar appication before, has something changed??

 

I have triple checked my code, "theUrl" is correct etc.

 

Thanks.

 

 

 

 

 

 

 

 

  • February 22, 2013
  • Like
  • 0

Hi,

     I'm wondering if anyone knows if there's a way to supply a String[] as a list of strings as a Param into a component,

 

Take this for an example:

VF page

<c:myComp dataPanel="STRING [] I WANT TO SUPPLY" />

 

COMPONENT

<apex:attribute name="dataPanel" description="String[]" type="String[]" required="false"/>

 

So far the only way I can supply a String[] is to create one in a controller and assisng it to dataPanel={!strArrayInController}

 

I find this messy if someone is using this compoent and only need supply a few strings in say Comma seperated format I would have imagined somehting like this exists:

 

<c:myComp dataPanel="new String[] {'one','two','three'}" />

 

 

Any idea's?

 

Thanks

 

  • January 28, 2013
  • Like
  • 0

Hi,

 

Im having problems applying CSS styles to <apex:outputfield> . I am displaying an image from a rich field. when I try to apply the float:right; css propertie it does not work.

 

Someone knows how to fix this?

 

Thanks in advance!

 

REG