• savvyboarder
  • NEWBIE
  • 25 Points
  • Member since 2008

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

I'm curious if anybody knows why I'm getting the error in the subject of this thread?  ^^^

 

 

test.starttest();

Profile p = [SELECT Id FROM profile WHERE name='API'];
User u1 = new User(alias = 'newUser', email='user@domain.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='user@domain.com');

insert u1;

system.debug('###### the user is: ' + u1.Id);

System.runAs(u1)
{

List<Opportunity> opptys = new List<Opportunity>();

Opportunity o1 = new Opportunity();
o1.Name = 'Test Oppty 1';
o1.CloseDate = Date.today();
o1.StageName = 'Reservation';
o1.Rental_Rate__c = 100;
opptys.add(o1);

Opportunity o2 = new Opportunity();
o2.Name = 'Test Oppty 2';
o2.CloseDate = Date.today();
o2.StageName = 'Appointment';
opptys.add(o2);

Opportunity o3 = new Opportunity();
o3.Name = 'Test Oppty 3';
o3.CloseDate = Date.today();
o3.StageName = 'Lead';
opptys.add(o3);


insert opptys;

system.debug('##### the opportunities are: ' + opptys);
system.debug('##### created by: ' + opptys[0].CreatedById);

}

test.stopTest();

 

 

 

Message Edited by savvyboarder on 06-10-2009 02:44 PM

Hi all-

 

I'm curious if anybody knows what I might be doing wrong here...

 

I'm trying to run this test as a different user, and it's setting the correct user, but the "CreatedById" isn't being populated when inserting.

 

Is there something I'm missing in the code?  

 

Cheers!!

 

 

// this tests trgCreateOpptyTask
// create a couple opptys and then update them with a unit_id
test.starttest();

Profile p = [SELECT Id FROM profile WHERE name='API'];

User u1 = new User(alias = 'newUser', email='user@mydomain.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='user@mydomain.com');

system.debug('###### the user is: ' + u1.Email);

System.runAs(u1)
{

List<Opportunity> opportunities = new List<Opportunity>();

Opportunity o1 = new Opportunity();
o1.Name = 'Test Oppty 1';
o1.CloseDate = Date.today();
o1.StageName = 'Reservation';
o1.Rental_Rate__c = 100;
opportunities.add(o1);

Opportunity o2 = new Opportunity();
o2.Name = 'Test Oppty 2';
o2.CloseDate = Date.today();
o2.StageName = 'Appointment';
opportunities.add(o2);

Opportunity o3 = new Opportunity();
o3.Name = 'Test Oppty 3';
o3.CloseDate = Date.today();
o3.StageName = 'Lead';
opportunities.add(o3);


insert opportunities;

 }

 

 

 

 

Message Edited by savvyboarder on 06-02-2009 09:27 AM
Message Edited by savvyboarder on 06-02-2009 09:29 AM

I'm curious if anybody knows how to simulate a document "attachment" to a case object?  I'm trying to write a test method that is attaching a document to the case.  Here is what I have for the test so far...

 

 

static testMethod void ContactNullTest() { test.starttest(); Case testCase = new Case(); testCase.ContactId = null; ApexPages.StandardController sc = new ApexPages.StandardController(testCase); hdWebForm scExt = new hdWebForm(sc); testCase = (Case)sc.getRecord(); Contact objContact; String UserDepartment; String UserLocation; ID currUserID = UserInfo.getUserID(); //UserID = currUserID; Boolean blnHasContactAssociated; test.stoptest(); }

 

 

 

Hi all-

 

Is there anyway to access the sandbox data with the SFDC Excel Connector? Any help is appreciated! 

 

BW

Hi all-

 

I'm wondering if there is a way to define a proxy in the HTTPRequest methods?  I'm trying to access a web service that requires authentication.  Perhaps I can authenticate using the setHeader? 

 

Here is an example of the service i'm trying to hit... 

 

http://findv3.staging.mappoint.net/Find-30/FindService.asmx?wsdl

 

 

Cheers, 

 

BW

Message Edited by savvyboarder on 04-01-2009 02:46 PM

Hi all-

 

Is there a way to assign a rule to a case programatically with Apex?  Similar to the way you would handle it using the Web Service API?

 

Thanks for the help!! 

Does anybody know if you can mark the "Assign using active assignment rule" as true using the API to create new leads? 

 

Cheers, 

 

BW

 

Hi all-

 

I'm curious if anybody can help me out here.  I'm trying to integrate an exact target xml api, and I'm getting a "Bad Request" when making this call.  However, the input string works fine if you post in a browser.  Is there something I'm missing?  The same code works fine for a different call to the exact target api.

 


 

 

public void addSubscriber() {

// add subscriber to list
// Get the XML document from the external server
Http http = new Http();
HttpRequest req = new HttpRequest();

String inputString = 'https://api.dc1.exacttarget.com/integrate.aspx?qf=xml&xml=<exacttarget><authorization><username>myusername</username><password>mypassword</password></authorization><system><system_name>subscriber</system_name><action>add</action><search_type>listid</search_type><search_value>371041</search_value><search_value2></search_value2><values><Email__Address>webmaster@extraspace.com</Email__Address><status>active</status><Full_Name>TESTING 123</Full_Name></values><update>true</update></system></exacttarget>';


req.setEndpoint(inputString);
req.setMethod('GET');


HttpResponse res = http.send(req);

// Log the XML content
System.debug(res.getBody());

// Generate the HTTP response as an XML stream
XmlStreamReader reader = res.getXmlStreamReader();

// Read through the XML
while(reader.hasNext()) {
System.debug('Event Type:' + reader.getEventType());
if (reader.getEventType() == XmlTag.START_ELEMENT) {
System.debug(reader.getLocalName());
}
reader.next();
}

}

 

 

Cheers, 

 

BW

 

Hi all-

 

I'm trying to convert another WSDL and i'm getting the following error.  What is the supported type for a byte?

 

Error: Unsupported schema type: {http://www.w3.org/2001/XMLSchema}byte

blank_page

Hi all-

 

I'm wondering if someone can help me figure out the solution to my problem.  I generated an apex class from the WSDL class generator, and this is part of the output. However, I have been told that I will need to ensure the the SOAP responses are described in the WSDL.  I'm not a SOAP expert so I don't know where to begin...  So, I have posted the two types of responses that come back from our web service provider as well as how its defined in the WSDL.   ANY help is greatly appreciated...

 

 

public csCallCenterWS.CreateNewAccountResult_element CreateNewAccount(String strUser,String strPin,Integer lngSiteID,String strFirstName,String strLastName,String strAccountName,String strAccountType,String strAddress1,String strAddress2,String strCity,String strState,String strZip,String strEmail,String strHomePhone) { csCallCenterWS.CreateNewAccount_element request_x = new csCallCenterWS.CreateNewAccount_element(); csCallCenterWS.CreateNewAccountResponse_element response_x; request_x.strUser = strUser; request_x.strPin = strPin; request_x.lngSiteID = lngSiteID; request_x.strFirstName = strFirstName; request_x.strLastName = strLastName; request_x.strAccountName = strAccountName; request_x.strAccountType = strAccountType; request_x.strAddress1 = strAddress1; request_x.strAddress2 = strAddress2; request_x.strCity = strCity; request_x.strState = strState; request_x.strZip = strZip; request_x.strEmail = strEmail; request_x.strHomePhone = strHomePhone; Map<String, csCallCenterWS.CreateNewAccountResponse_element> response_map_x = new Map<String, csCallCenterWS.CreateNewAccountResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://centershift.com/csCallCenter/csCallCenterService/CreateNewAccount', 'http://centershift.com/csCallCenter/csCallCenterService', 'CreateNewAccount', 'http://centershift.com/csCallCenter/csCallCenterService', 'CreateNewAccountResponse', 'csCallCenterWS.CreateNewAccountResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.CreateNewAccountResult; }

 

 

 

EXPECTED XML RESPONSE

 

ERROR

 

      <Error>
        <ErrorCode>100</ErrorCode>
        <Line>445</Line>
        <Message>Failed to log in User:  Either Username or Password is incorrect or User does not have permission</Message>
      </Error>

 

SUCCESS

 

      <Account>
        <FIRST_NAME>frank</FIRST_NAME>
        <LAST_NAME>sinatra</LAST_NAME>
        <EMAIL_ADDRESS>test@example.com</EMAIL_ADDESS>
        <PASSWORD>438500</PASSWORD>
        <CONTACT_ID>5662413</CONTACT_ID>
        <ACCOUNT_ID>3072405</ACCOUNT_ID>
      </Account>

 

 

HERE IS HOW THE RESPONSE IS DEFINED IN THE WSDL

 

      <s:element name="CreateNewAccountResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="CreateNewAccountResult">
              <s:complexType mixed="true">
                <s:sequence>
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>

Message Edited by savvyboarder on 02-02-2009 09:03 AM
Message Edited by savvyboarder on 02-02-2009 09:58 AM

Hi all-

 

I'm wondering if anybody knows a good place to start finding ways to access and execute an external web service using Apex.  Any help is appreciated!!

 

BW

I attended a training session at DreamForce, and I remember updating apex code in a browser.  Does anybody know where I can find the plugin, or if Eclipse is the only way to edit both Visualforce and Apex?

Have a great day!

Thanks,

Brett


Message Edited by savvyboarder on 11-09-2008 03:50 PM
Is there a constant for Pi that I just cant find? Its easy enough to define a Double with a pre-defined value in it, but I would assume that there was something in Math for it.

Hi all-

 

I'm curious if anybody knows what I might be doing wrong here...

 

I'm trying to run this test as a different user, and it's setting the correct user, but the "CreatedById" isn't being populated when inserting.

 

Is there something I'm missing in the code?  

 

Cheers!!

 

 

// this tests trgCreateOpptyTask
// create a couple opptys and then update them with a unit_id
test.starttest();

Profile p = [SELECT Id FROM profile WHERE name='API'];

User u1 = new User(alias = 'newUser', email='user@mydomain.com',
emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='user@mydomain.com');

system.debug('###### the user is: ' + u1.Email);

System.runAs(u1)
{

List<Opportunity> opportunities = new List<Opportunity>();

Opportunity o1 = new Opportunity();
o1.Name = 'Test Oppty 1';
o1.CloseDate = Date.today();
o1.StageName = 'Reservation';
o1.Rental_Rate__c = 100;
opportunities.add(o1);

Opportunity o2 = new Opportunity();
o2.Name = 'Test Oppty 2';
o2.CloseDate = Date.today();
o2.StageName = 'Appointment';
opportunities.add(o2);

Opportunity o3 = new Opportunity();
o3.Name = 'Test Oppty 3';
o3.CloseDate = Date.today();
o3.StageName = 'Lead';
opportunities.add(o3);


insert opportunities;

 }

 

 

 

 

Message Edited by savvyboarder on 06-02-2009 09:27 AM
Message Edited by savvyboarder on 06-02-2009 09:29 AM

Does anybody know if you can mark the "Assign using active assignment rule" as true using the API to create new leads? 

 

Cheers, 

 

BW

 

Hi all-

 

I'm curious if anybody can help me out here.  I'm trying to integrate an exact target xml api, and I'm getting a "Bad Request" when making this call.  However, the input string works fine if you post in a browser.  Is there something I'm missing?  The same code works fine for a different call to the exact target api.

 


 

 

public void addSubscriber() {

// add subscriber to list
// Get the XML document from the external server
Http http = new Http();
HttpRequest req = new HttpRequest();

String inputString = 'https://api.dc1.exacttarget.com/integrate.aspx?qf=xml&xml=<exacttarget><authorization><username>myusername</username><password>mypassword</password></authorization><system><system_name>subscriber</system_name><action>add</action><search_type>listid</search_type><search_value>371041</search_value><search_value2></search_value2><values><Email__Address>webmaster@extraspace.com</Email__Address><status>active</status><Full_Name>TESTING 123</Full_Name></values><update>true</update></system></exacttarget>';


req.setEndpoint(inputString);
req.setMethod('GET');


HttpResponse res = http.send(req);

// Log the XML content
System.debug(res.getBody());

// Generate the HTTP response as an XML stream
XmlStreamReader reader = res.getXmlStreamReader();

// Read through the XML
while(reader.hasNext()) {
System.debug('Event Type:' + reader.getEventType());
if (reader.getEventType() == XmlTag.START_ELEMENT) {
System.debug(reader.getLocalName());
}
reader.next();
}

}

 

 

Cheers, 

 

BW

 

Hi all-

 

I'm trying to convert another WSDL and i'm getting the following error.  What is the supported type for a byte?

 

Error: Unsupported schema type: {http://www.w3.org/2001/XMLSchema}byte

blank_page

Hi all-

 

I'm wondering if someone can help me figure out the solution to my problem.  I generated an apex class from the WSDL class generator, and this is part of the output. However, I have been told that I will need to ensure the the SOAP responses are described in the WSDL.  I'm not a SOAP expert so I don't know where to begin...  So, I have posted the two types of responses that come back from our web service provider as well as how its defined in the WSDL.   ANY help is greatly appreciated...

 

 

public csCallCenterWS.CreateNewAccountResult_element CreateNewAccount(String strUser,String strPin,Integer lngSiteID,String strFirstName,String strLastName,String strAccountName,String strAccountType,String strAddress1,String strAddress2,String strCity,String strState,String strZip,String strEmail,String strHomePhone) { csCallCenterWS.CreateNewAccount_element request_x = new csCallCenterWS.CreateNewAccount_element(); csCallCenterWS.CreateNewAccountResponse_element response_x; request_x.strUser = strUser; request_x.strPin = strPin; request_x.lngSiteID = lngSiteID; request_x.strFirstName = strFirstName; request_x.strLastName = strLastName; request_x.strAccountName = strAccountName; request_x.strAccountType = strAccountType; request_x.strAddress1 = strAddress1; request_x.strAddress2 = strAddress2; request_x.strCity = strCity; request_x.strState = strState; request_x.strZip = strZip; request_x.strEmail = strEmail; request_x.strHomePhone = strHomePhone; Map<String, csCallCenterWS.CreateNewAccountResponse_element> response_map_x = new Map<String, csCallCenterWS.CreateNewAccountResponse_element>(); response_map_x.put('response_x', response_x); WebServiceCallout.invoke( this, request_x, response_map_x, new String[]{endpoint_x, 'http://centershift.com/csCallCenter/csCallCenterService/CreateNewAccount', 'http://centershift.com/csCallCenter/csCallCenterService', 'CreateNewAccount', 'http://centershift.com/csCallCenter/csCallCenterService', 'CreateNewAccountResponse', 'csCallCenterWS.CreateNewAccountResponse_element'} ); response_x = response_map_x.get('response_x'); return response_x.CreateNewAccountResult; }

 

 

 

EXPECTED XML RESPONSE

 

ERROR

 

      <Error>
        <ErrorCode>100</ErrorCode>
        <Line>445</Line>
        <Message>Failed to log in User:  Either Username or Password is incorrect or User does not have permission</Message>
      </Error>

 

SUCCESS

 

      <Account>
        <FIRST_NAME>frank</FIRST_NAME>
        <LAST_NAME>sinatra</LAST_NAME>
        <EMAIL_ADDRESS>test@example.com</EMAIL_ADDESS>
        <PASSWORD>438500</PASSWORD>
        <CONTACT_ID>5662413</CONTACT_ID>
        <ACCOUNT_ID>3072405</ACCOUNT_ID>
      </Account>

 

 

HERE IS HOW THE RESPONSE IS DEFINED IN THE WSDL

 

      <s:element name="CreateNewAccountResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="CreateNewAccountResult">
              <s:complexType mixed="true">
                <s:sequence>
                  <s:any />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>

Message Edited by savvyboarder on 02-02-2009 09:03 AM
Message Edited by savvyboarder on 02-02-2009 09:58 AM