• dujsu
  • NEWBIE
  • 60 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 25
    Replies

We have got a custom child object called Billed_Account__c that contains a lookup (Custom_Account__c) field to the Account object and I am trying to write a query to get the child records from the parent.

 

So here is the latest SOQL query that does not work...

 

Select Id, Name, (Select Id, Name From Customer_Account__r) From Account 

 

Im receiving the following error: "INVALID TYPE:...Didn't understand relationship 'Customer_Account__r' in FROM part of query call......."

 

Any advice is appreciated.

 

Thanks!

 

 

 

 

 

  • October 03, 2012
  • Like
  • 0

Are there any data model comparison tools available?  I'd like to compare objects and fields in our TEST environment to our PRODUCTION environment objects and fields. Are there any tools that will provide this type of information?

  • August 02, 2012
  • Like
  • 0

I have an Apex Class that generates a WSDL and am able to view the WSDL via URL to the specific server address (ie. "NA0.salesforce.com"). We also have a SF DNS alias, ourcompany.my.salesforce.com, but I am not able to view the generated WSDL. 

 

Why would this be happening? Do I need to submit this as an issue?

 

 

  • July 23, 2012
  • Like
  • 0

Im trying to write a test case for a webservice and could use a nudge. This is probably a VERY basic concept that I am missing. Any assistance is appreciated.

 

Here is the psuedo webservice that I have built:

 

global class theWS {
 	 
 	 global class RequestArguments {
	 	webservice string AValue;
	 }
 	 
 	 global class ResponseArguments {
 	 	webservice string AID;
 	 	webservice string AName;
 	 }
	 
 	 webservice static ResponseArguments[] DescribeObject(RequestArguments Request) {
 	 	
 	 	List<ResponseArguments> bList = new List<ResponseArguments>();
 	 	
 	 	if(Request.AValue != null){
 	 		
			List<MyObject__c> bList = new List<MyObject__c>([SELECT ID, 
						Name									
						FROM MyObject
						where Name = :Request.AValue
						LIMIT 1]);
										
				for (Integer i=0;i<buildList.size();i++) {
				  ResponseArguments ra = new ResponseArguments();
				  ra.AID = buildList.get(i).ID;
				  ra.AName = buildList.get(i).Name;
				  bList.add(ra);
				}
			
 	 	} 
	 	return bList;
	 }
}

 Here is my test case thus far (my question is below):

 

@isTest
private class Test_theWS {

    static testMethod void test_SimpleRequest() {

        
        theWS.RequestArguments reqArgs = new theWS.RequestArguments(); 
        reqArgs.AValue = 'A';
        
        List<theWS.ResponseArguments> blist = theWS.DescribeObject(reqArgs);

	system.assert(true, bList.size() > 0);
  
    }
}

 QUESTION: Im trying to assign "A" value to reqArgs.AValue, but it doesn't appear to be getting passed in the collection following (DescribeObject(reqArgs)). How do I properly assign a value to reqArgs.AValue?

 

 

Thanks ahead of time!

  • July 11, 2012
  • Like
  • 0

Is there a way to add/remove objects that are available to the client application (see below)?  We are having an issue with objects not showing up in the list, both standard and custom.

 

Definition below can be found here: http://www.salesforce.com/us/developer/docs/officetoolkit/index_Left.htm#StartTopic=Content%2Fsforce...

 

EntityNamesVariantString array containing the names of all Force.com objects that are available to the client application. Each array element represents a separate object type.
  • June 20, 2012
  • Like
  • 0

Is there a way to add/remove objects that are available to the client application (see below)?  We are having an issue with objects not showing up in the list, both standard and custom.

 

Definition below can be found here: http://www.salesforce.com/us/developer/docs/officetoolkit/index_Left.htm#StartTopic=Content%2Fsforce_api_comobjects_sforcesession3.htm|SkinName=webhelp

 

EntityNamesVariantString array containing the names of all Force.com objects that are available to the client application. Each array element represents a separate object type.
  • June 20, 2012
  • Like
  • 0

Hello,

 

Im working on a test class for an external webservice and having issues with converting a dummy XML (String) into a Type Dom.XMLNode. I need to figure out a way to kick off the 'walkthrough' method from my test class in order to get my percentages up. So any advice is appreciated.

 

Test class - based on this article here: http://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/

 

 

... 
try { 
 if(!isApexTest){ 
    HTTPResponse res = http.send(req); 
    Dom.Document doc = res.getBodyDocument(); 
    Dom.XMLNode root = doc.getRootElement(); 
 }else{ 
    //error occurs here because Im trying to give DOM.XMLNode a String

    DOM.XMLNode root = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddFolderResponse xmlns="http://blahns"><AddFolderResult><<ObjectID>​1234567890</ObjectID></AddFolderResult></AddFolder​Response></soap:Body></soap:Envelope>'; 
 } 
 xObjectID = walkthrough(root, 'ObjectID').trim();

  return xObjectID; 

} catch(System.CalloutException e){ 
  return e.getMessage(); 
} 
...

 

 

 

Walkthrough Method: based on article found here:  http://developer.force.com/cookbook/recipe/parsing-xml-using-the-apex-dom-parser

 

	public static String walkThrough(DOM.XMLNode node, String field) {
		String result = '\n';
		
		if(node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
			
			if(node.getName().trim() == field) {
				result += node.getText().trim();
			}
			
			for(DOM.XMLNode child : node.getChildElements()) {
				result += walkThrough(child, field);
			}
			return result;
		}
		return 'ERROR';
	}

 

 

  • June 15, 2012
  • Like
  • 0

Hello,

 

How do I view the details of a Deployment? If possible, I'd like to see an IP address of the person that performed the deployment and a list of files that were deployed. Is this possible? Ive tried putting the deployment ID into the URL but I get Insufficient Privileges.

 

A deployment went to production this morning at 8:23 AM (see attached) using my SF Account and I never kicked off any deployment. If this information is not available I will probably have put in a ticket to investigate it further. 

 

All information or suggestions are appreciated.

Deployments

  • June 11, 2012
  • Like
  • 0

What is the best way to merge the two Lists below in Apex or VisualForce? The data is related, but cannot be queried together, so I need to combine the two Lists.

 

Things to note:

1. The two lists: the additionalInfoQuestionMaps is the parent List and the additionalInfoQuestionAvailableResponses is the child. There can be 1 to many children.

2. I need to join the Lists on the Question_Type_Info__c object.

 

Basically its a set of Questions coming from the Parent List, then I need to associate possible answers to those questions such as Yes and No that reside in the Child List. Those results will be displayed on a VF page in a form.

 

 

public with sharing class mytest {
	
    public List<Questions__c> additionalInfoQuestionMaps {get;set;}
    public List<Available_Question_Answer_Options__c> additionalInfoQuestionAvailableResponses {get;set;} 
    public List<retrieveMergedQuestionList> retrieveMergedQuestionLists {get;set;}
    
    public String buildId {get;set;}
    
    public Build__c build {get;set;}
    
    public mytest() {
    
        buildId = 'a1DV00000001BBBBBB';
        build = sharedfile.getBuild(buildId);
        updateAdditionalInfoQuestionMaps();
        updateAdditionalInfoFieldValueIds();
        updateAdditionalInfoQuestionAvailableResponses();
    }
    
    public void updateAdditionalInfoQuestionMaps() {
			
			additionalInfoQuestionMaps = new List<Questions__c>([SELECT Id, Name, 
						  Associated_Product_Item__c, 
						  Associated_Product__c, 
						  Label__c,
						     (select Response__c from Responses_Object__r),  
						  Question_Type_Info__c,  
						  Required__c
					FROM Questions__c                
	               	WHERE Associated_Product__c = :build.Associated_Product__c 
	                ORDER BY Sort_Index__c, Label__c]);
    }
    
    public Set<Id> additionalInfoFieldValueIds = new Set<Id>();
    
    public void updateAdditionalInfoFieldValueIds(){
        for (Questions__c aimb : additionalInfoQuestionMaps) {
                additionalInfoFieldValueIds.add(aimb.Question_Type_Info__c);
        }
    }

    public void updateAdditionalInfoQuestionAvailableResponses() {
    		additionalInfoQuestionAvailableResponses = new List<Available_Question_Answer_Options__c>([select Id,
    					Field_Value__c, Question_Type_Info__c
						from Available_Question_Answer_Options__c
						where Question_Type_Info__c IN :additionalInfoFieldValueIds]);

    }			
	
}

 

  • May 24, 2012
  • Like
  • 0

 

Hello,

 

Im all of a sudden getting the following error from my class that invokes a webservice:

ERROR:System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

 

Webservice Class

 

global class myWS   
{   
   
   WebService static string invokeExternalWs(string childValue, string parentValue)   
    {   
        HttpRequest req = new HttpRequest();   
        req.setEndpoint('https://externalURL/Services');   
        req.setMethod('POST');   
        req.setHeader('Content-Type', 'text/xml; charset=utf-8');   
        req.setHeader('SOAPAction', 'http://externalService/externalMethod');  
        string b = '--soap request goes here--';   
        req.setBody(b);   
        Http http = new Http();   
        try {   
          //Execute web service call here 
          String xObjectID ='';   
          HTTPResponse res = http.send(req);
          Dom.Document doc = res.getBodyDocument();
          String soapNS = 'http://schemas.xmlsoap.org/soap/envelope/'; 
          Dom.XmlNode root = doc.getRootElement();
          for(dom.XmlNode node1 : root.getChildElements()) {
               for(dom.XmlNode node2 : node1.getChildElements()) {
                   for(dom.XmlNode node3 : node2.getChildElements()) {
                      for(dom.XmlNode node4 : node3.getChildElements()) {
                          xObjectID = node4.getText();
                       }
                   }
               }
             }
     
         return xObjectID;
       } catch(System.CalloutException e){   
          return 'ERROR:' + e;   
     }          
}   
}

 UPDATE: Here is my class that is executing myWS

public void applyURLString(ID ArgBuildID) {

    Builder__c current_build = [SELECT id, name, LLURL__c, column1, column2, Opportunity__c
                FROM Builder__c
                WHERE id = :ArgBuildID];

        if(current_build.LLURL__c == null || current_build.LLURL__c.trim().length() == 0)
            {

                String tmpFolderName = current_build.column1 + ' - ' + current_build.column2;

                String LLWSResultPattern = '[0-9]{2,}';

                String myWSXMLResult = myWS.invokeExternalWs(tmpFolderName,'test');

                Boolean LLWSPatternMatched = pattern.matches(LLWSResultPattern,myWSXMLResult);
                if(LLWSPatternMatched)
                {
                    Opportunity oppt = [SELECT Id,Name 
                                        FROM Opportunity 
                                        WHERE Id = :current_build.Opportunity__c
                                        LIMIT 1];   
                    oppt.LLURL__c = 'https://someService/' + myWSXMLResult;
                    update oppt;
                } 
            } 
    }

 

 

UPDATE #2 - Here is the code that executes applyURLString()

 

 

Builder__c insertBuild = new Builder__c();      
insertBuild.Opportunity__c = opportunityId;
insertBuild.Product_Group__c = selectedBuild.Product_Group__c;
insertBuild.Manual_Build_Product__c = selectedBuild.Manual_Build_Product__c;

insert insertBuild;

applyURLString(insertBuild.Id);

 

 

 

Thank you for your time!

  • May 09, 2012
  • Like
  • 0

Hello,

 

Im new to APEX and could use a nudge here. Im trying to update a custom field with the Opportunity object and am getting the following error below. 

 

Visual Force Error: System.NullPointerException: Attempt to de-reference a null object 

 


Code

 

public with sharing class myTestClass{
	
	public MyCustomBuildObject__c build {get;set;}
	public String myWSXMLResult {get;set;}  
	public String getWSXMLResult() {
		

		build = ip_shared_updateMethods.getBuild('a1DV00000000jK4MAI');
		if(build.Opportunity__r.LiveLink_URL__c == null && build.Product_Group__r.Engineering_Engagement__c == 'Required')
		{
			String tmpFolderName = build.Opportunity__r.Account.Name + ' - ' + build.Opportunity__r.Custom_Contract_Number__c;
			String wordCharPattern = '[^_A-Za-z0-9-\\s]';
			String LLWSResultPattern = '[0-9]{2,}';
			Pattern compiledWordCharPattern = pattern.compile(wordCharPattern);
			Matcher wordCharMatcher = compiledWordCharPattern.matcher(tmpFolderName);
			tmpFolderName = wordCharMatcher.replaceAll('');
			tmpFolderName = tmpFolderName.replaceAll('  ',' ');
			
			DSPA__c dsp = DSPA__c.getInstance();
			String tmpObjectID = dsp.DSPID__c;
			
			String myWSXMLResult = another_class.invokeWs(tmpFolderName,tmpObjectID);
			
			Boolean LLWSPatternMatched = pattern.matches(LLWSResultPattern,myWSXMLResult);
			
			if(LLWSPatternMatched)
			{
				/******Error occurs on line below******/
				build.Opportunity__r.LLURL__c = 'https://internalService/' + myWSXMLResult;
				update build;
			} 
			
		} 
		return myWSXMLResult;
	}
}

 

This is where the error is pointing to..

 

/******Error occurs on line below******/
build.Opportunity__r.LLURL__c = 'https://internalService/' + myWSXMLResult;

Im sure this is an easy one, thanks ahead of time for the advice.

  • May 07, 2012
  • Like
  • 0

Hello,

 

Im curious if there is tool similar to Toad or SQL Managment Studio for the SF data model? I want to run queries without having to export my results. I also want to be able to copy/paste values from my query results (such as ID's and other column values). I am unable to copy/paste the values from the Schema view in Eclipse. Im guessing thats to prevent editing the data. And I know I can find IDs in the URL, but would prefer retrieving the values through running a specific query.

 

Is there such a tool? All input is appreciated.

 

Edited: Just found SoqlXplorer by devangel, but that tool looks to be Mac only. 

 

 

Thanks ahead of time.

  • May 04, 2012
  • Like
  • 0

Hello all,

 

I could use some general assistance with a simple bit of Apex code. Just so you know I am a newbie to Salesforce.com, but not to web application programming (12 years but with Coldfusion and some Perl and am used to the MVC architecture), although I have not been exposed deeply to Java or C#.

 

So I am working on a simple controller that I'll use in a simple VF page. I'd just like to return the value and display it on the page but Im running into some syntax issues during compile. Here's my code so far:

 

Controller - mytest.cls

public with sharing class myTest {

	public class addNewFolder {
		
		String tmpFolderName = 'MyTestFolder';
		String tmpObjectID = '22K22'; 
		
		String tmpResult = 'Whoo-hoo!';
		System.debug('XIX|' + tmpResult);
		return tmpResult;
		
	}

}

Error

 

Description Resource Path Location Type
Save error: expecting a right parentheses, found 'XIX|' mytest.cls /PREPROD/src/classes line 15 Force.com save problem

 

 

  • April 30, 2012
  • Like
  • 0

Im new to Salesforce in general and Im trying to decide how to handle the invoking of a SOAP webservice. Currently the webservice is being executed via AJAX when a user clicks a button on the Opportunity page. I have been asked to move the webservice invocation from the button and place it into a custom controller page. So the webservice needs to be invoked seamlessly when certain conditions are met, opposed to having the user click a button.

 

I'd like to just kick off the webservice using the same ajax statement because it will save me time. Although it would seem to make more sense to invoke the webservice via Apex, but am still researching that topic.

 

So here is my question: Is it possible to execute the following javascript from within an Apex controller? If so how?

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
var xfolder = "MyNewFolder"
var parentid = "999999999999999"
var myvar = sforce.apex.execute("myWS","invokeExternalWs", {folderName:xfolder,ObjectID:parentid});
window.alert('Folder created: ' + myvar);

 

  • April 27, 2012
  • Like
  • 0

Hello,

 

I have generated a WSDL from a class I have created. I can see the generated XML in the browser, and everything looks fine, but I am having trouble consuming the webservice with the URL I am using to view the XML. I have changed the URL to server specific as well, but still having issues, so like this:

 

https://cs12.salesforce.com/services/wsdl/class/WS_TEST_WSDL

 

But the result just redirects me to the login screen. Status says OK though.

 

Here is my XML I am sending to the URL above:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://soap.sforce.com/schemas/class/WS_TEST_WSDL">
<soapenv:Header>

<ws:SessionHeader>
<ws:sessionId>my token value from the login goes here</ws:sessionId>
</ws:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<ws:DescribeFields/>
</soapenv:Body>
</soapenv:Envelope>

 

Does this look correct?  Since Im passing the SessionID I would assume there is no need to login again?

 

Also, I shouldn't need to setup any kind of Remote Access as I do with a REST API, is this a correct assumption as well?

 

All input is appreciated. Thanks!

 

  • April 23, 2012
  • Like
  • 0

Hello,

 

Im trying to consume a WSDL in our SFDC instance and am receiving the following response:

 

<!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"> <script> var escapedHash = ''; var url = 'https://test.salesforce.com/FAKEWSDLNAME'; if (window.location.hash) { escapedHash = '%23' + window.location.hash.slice(1); } if (window.location.replace){ window.location.replace(url + escapedHash); } else {; window.location.href = url + escapedHash; } </script> </head> </html> <!-- ................................................................................................... ................................................................................................... ................................................................................................... ................................................................................................... -->

 

Why does this happen and what do I need to do with it? 

 

All suggestions are appreciated.

 

Thanks ahead!

  • April 20, 2012
  • Like
  • 0
Hello - I am trying to figure out how to set a custom field value that resides within the Activity object to the value of Task.ActivityDate. I am not sure how to reference the custom field (Activity.Activity_Due_Date__c) properly in my for loop below.

trigger GetUsableTaskDueDate on Task (before insert, before update) {
    Task[] checkTasks = Trigger.new; 
    for(Task t : checkTasks){ 
        Activity.Activity_Due_Date__c = t.ActivityDate;
    }
}

This is my 4th day learning SF and my first real task. I am a 12 year veteran web app developer and this task seems like it should be trivial.

All suggestions are appreciated.

Thanks!
  • April 10, 2012
  • Like
  • 0

Im trying to write a test case for a webservice and could use a nudge. This is probably a VERY basic concept that I am missing. Any assistance is appreciated.

 

Here is the psuedo webservice that I have built:

 

global class theWS {
 	 
 	 global class RequestArguments {
	 	webservice string AValue;
	 }
 	 
 	 global class ResponseArguments {
 	 	webservice string AID;
 	 	webservice string AName;
 	 }
	 
 	 webservice static ResponseArguments[] DescribeObject(RequestArguments Request) {
 	 	
 	 	List<ResponseArguments> bList = new List<ResponseArguments>();
 	 	
 	 	if(Request.AValue != null){
 	 		
			List<MyObject__c> bList = new List<MyObject__c>([SELECT ID, 
						Name									
						FROM MyObject
						where Name = :Request.AValue
						LIMIT 1]);
										
				for (Integer i=0;i<buildList.size();i++) {
				  ResponseArguments ra = new ResponseArguments();
				  ra.AID = buildList.get(i).ID;
				  ra.AName = buildList.get(i).Name;
				  bList.add(ra);
				}
			
 	 	} 
	 	return bList;
	 }
}

 Here is my test case thus far (my question is below):

 

@isTest
private class Test_theWS {

    static testMethod void test_SimpleRequest() {

        
        theWS.RequestArguments reqArgs = new theWS.RequestArguments(); 
        reqArgs.AValue = 'A';
        
        List<theWS.ResponseArguments> blist = theWS.DescribeObject(reqArgs);

	system.assert(true, bList.size() > 0);
  
    }
}

 QUESTION: Im trying to assign "A" value to reqArgs.AValue, but it doesn't appear to be getting passed in the collection following (DescribeObject(reqArgs)). How do I properly assign a value to reqArgs.AValue?

 

 

Thanks ahead of time!

  • July 11, 2012
  • Like
  • 0

Is there a way to add/remove objects that are available to the client application (see below)?  We are having an issue with objects not showing up in the list, both standard and custom.

 

Definition below can be found here: http://www.salesforce.com/us/developer/docs/officetoolkit/index_Left.htm#StartTopic=Content%2Fsforce...

 

EntityNamesVariantString array containing the names of all Force.com objects that are available to the client application. Each array element represents a separate object type.
  • June 20, 2012
  • Like
  • 0

Hello,

 

Im working on a test class for an external webservice and having issues with converting a dummy XML (String) into a Type Dom.XMLNode. I need to figure out a way to kick off the 'walkthrough' method from my test class in order to get my percentages up. So any advice is appreciated.

 

Test class - based on this article here: http://sfdc.arrowpointe.com/2009/05/01/testing-http-callouts/

 

 

... 
try { 
 if(!isApexTest){ 
    HTTPResponse res = http.send(req); 
    Dom.Document doc = res.getBodyDocument(); 
    Dom.XMLNode root = doc.getRootElement(); 
 }else{ 
    //error occurs here because Im trying to give DOM.XMLNode a String

    DOM.XMLNode root = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddFolderResponse xmlns="http://blahns"><AddFolderResult><<ObjectID>​1234567890</ObjectID></AddFolderResult></AddFolder​Response></soap:Body></soap:Envelope>'; 
 } 
 xObjectID = walkthrough(root, 'ObjectID').trim();

  return xObjectID; 

} catch(System.CalloutException e){ 
  return e.getMessage(); 
} 
...

 

 

 

Walkthrough Method: based on article found here:  http://developer.force.com/cookbook/recipe/parsing-xml-using-the-apex-dom-parser

 

	public static String walkThrough(DOM.XMLNode node, String field) {
		String result = '\n';
		
		if(node.getNodeType() == DOM.XMLNodeType.ELEMENT) {
			
			if(node.getName().trim() == field) {
				result += node.getText().trim();
			}
			
			for(DOM.XMLNode child : node.getChildElements()) {
				result += walkThrough(child, field);
			}
			return result;
		}
		return 'ERROR';
	}

 

 

  • June 15, 2012
  • Like
  • 0

Hello,

 

How do I view the details of a Deployment? If possible, I'd like to see an IP address of the person that performed the deployment and a list of files that were deployed. Is this possible? Ive tried putting the deployment ID into the URL but I get Insufficient Privileges.

 

A deployment went to production this morning at 8:23 AM (see attached) using my SF Account and I never kicked off any deployment. If this information is not available I will probably have put in a ticket to investigate it further. 

 

All information or suggestions are appreciated.

Deployments

  • June 11, 2012
  • Like
  • 0

What is the best way to merge the two Lists below in Apex or VisualForce? The data is related, but cannot be queried together, so I need to combine the two Lists.

 

Things to note:

1. The two lists: the additionalInfoQuestionMaps is the parent List and the additionalInfoQuestionAvailableResponses is the child. There can be 1 to many children.

2. I need to join the Lists on the Question_Type_Info__c object.

 

Basically its a set of Questions coming from the Parent List, then I need to associate possible answers to those questions such as Yes and No that reside in the Child List. Those results will be displayed on a VF page in a form.

 

 

public with sharing class mytest {
	
    public List<Questions__c> additionalInfoQuestionMaps {get;set;}
    public List<Available_Question_Answer_Options__c> additionalInfoQuestionAvailableResponses {get;set;} 
    public List<retrieveMergedQuestionList> retrieveMergedQuestionLists {get;set;}
    
    public String buildId {get;set;}
    
    public Build__c build {get;set;}
    
    public mytest() {
    
        buildId = 'a1DV00000001BBBBBB';
        build = sharedfile.getBuild(buildId);
        updateAdditionalInfoQuestionMaps();
        updateAdditionalInfoFieldValueIds();
        updateAdditionalInfoQuestionAvailableResponses();
    }
    
    public void updateAdditionalInfoQuestionMaps() {
			
			additionalInfoQuestionMaps = new List<Questions__c>([SELECT Id, Name, 
						  Associated_Product_Item__c, 
						  Associated_Product__c, 
						  Label__c,
						     (select Response__c from Responses_Object__r),  
						  Question_Type_Info__c,  
						  Required__c
					FROM Questions__c                
	               	WHERE Associated_Product__c = :build.Associated_Product__c 
	                ORDER BY Sort_Index__c, Label__c]);
    }
    
    public Set<Id> additionalInfoFieldValueIds = new Set<Id>();
    
    public void updateAdditionalInfoFieldValueIds(){
        for (Questions__c aimb : additionalInfoQuestionMaps) {
                additionalInfoFieldValueIds.add(aimb.Question_Type_Info__c);
        }
    }

    public void updateAdditionalInfoQuestionAvailableResponses() {
    		additionalInfoQuestionAvailableResponses = new List<Available_Question_Answer_Options__c>([select Id,
    					Field_Value__c, Question_Type_Info__c
						from Available_Question_Answer_Options__c
						where Question_Type_Info__c IN :additionalInfoFieldValueIds]);

    }			
	
}

 

  • May 24, 2012
  • Like
  • 0

 

Hello,

 

Im all of a sudden getting the following error from my class that invokes a webservice:

ERROR:System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

 

Webservice Class

 

global class myWS   
{   
   
   WebService static string invokeExternalWs(string childValue, string parentValue)   
    {   
        HttpRequest req = new HttpRequest();   
        req.setEndpoint('https://externalURL/Services');   
        req.setMethod('POST');   
        req.setHeader('Content-Type', 'text/xml; charset=utf-8');   
        req.setHeader('SOAPAction', 'http://externalService/externalMethod');  
        string b = '--soap request goes here--';   
        req.setBody(b);   
        Http http = new Http();   
        try {   
          //Execute web service call here 
          String xObjectID ='';   
          HTTPResponse res = http.send(req);
          Dom.Document doc = res.getBodyDocument();
          String soapNS = 'http://schemas.xmlsoap.org/soap/envelope/'; 
          Dom.XmlNode root = doc.getRootElement();
          for(dom.XmlNode node1 : root.getChildElements()) {
               for(dom.XmlNode node2 : node1.getChildElements()) {
                   for(dom.XmlNode node3 : node2.getChildElements()) {
                      for(dom.XmlNode node4 : node3.getChildElements()) {
                          xObjectID = node4.getText();
                       }
                   }
               }
             }
     
         return xObjectID;
       } catch(System.CalloutException e){   
          return 'ERROR:' + e;   
     }          
}   
}

 UPDATE: Here is my class that is executing myWS

public void applyURLString(ID ArgBuildID) {

    Builder__c current_build = [SELECT id, name, LLURL__c, column1, column2, Opportunity__c
                FROM Builder__c
                WHERE id = :ArgBuildID];

        if(current_build.LLURL__c == null || current_build.LLURL__c.trim().length() == 0)
            {

                String tmpFolderName = current_build.column1 + ' - ' + current_build.column2;

                String LLWSResultPattern = '[0-9]{2,}';

                String myWSXMLResult = myWS.invokeExternalWs(tmpFolderName,'test');

                Boolean LLWSPatternMatched = pattern.matches(LLWSResultPattern,myWSXMLResult);
                if(LLWSPatternMatched)
                {
                    Opportunity oppt = [SELECT Id,Name 
                                        FROM Opportunity 
                                        WHERE Id = :current_build.Opportunity__c
                                        LIMIT 1];   
                    oppt.LLURL__c = 'https://someService/' + myWSXMLResult;
                    update oppt;
                } 
            } 
    }

 

 

UPDATE #2 - Here is the code that executes applyURLString()

 

 

Builder__c insertBuild = new Builder__c();      
insertBuild.Opportunity__c = opportunityId;
insertBuild.Product_Group__c = selectedBuild.Product_Group__c;
insertBuild.Manual_Build_Product__c = selectedBuild.Manual_Build_Product__c;

insert insertBuild;

applyURLString(insertBuild.Id);

 

 

 

Thank you for your time!

  • May 09, 2012
  • Like
  • 0

Hello,

 

Im new to APEX and could use a nudge here. Im trying to update a custom field with the Opportunity object and am getting the following error below. 

 

Visual Force Error: System.NullPointerException: Attempt to de-reference a null object 

 


Code

 

public with sharing class myTestClass{
	
	public MyCustomBuildObject__c build {get;set;}
	public String myWSXMLResult {get;set;}  
	public String getWSXMLResult() {
		

		build = ip_shared_updateMethods.getBuild('a1DV00000000jK4MAI');
		if(build.Opportunity__r.LiveLink_URL__c == null && build.Product_Group__r.Engineering_Engagement__c == 'Required')
		{
			String tmpFolderName = build.Opportunity__r.Account.Name + ' - ' + build.Opportunity__r.Custom_Contract_Number__c;
			String wordCharPattern = '[^_A-Za-z0-9-\\s]';
			String LLWSResultPattern = '[0-9]{2,}';
			Pattern compiledWordCharPattern = pattern.compile(wordCharPattern);
			Matcher wordCharMatcher = compiledWordCharPattern.matcher(tmpFolderName);
			tmpFolderName = wordCharMatcher.replaceAll('');
			tmpFolderName = tmpFolderName.replaceAll('  ',' ');
			
			DSPA__c dsp = DSPA__c.getInstance();
			String tmpObjectID = dsp.DSPID__c;
			
			String myWSXMLResult = another_class.invokeWs(tmpFolderName,tmpObjectID);
			
			Boolean LLWSPatternMatched = pattern.matches(LLWSResultPattern,myWSXMLResult);
			
			if(LLWSPatternMatched)
			{
				/******Error occurs on line below******/
				build.Opportunity__r.LLURL__c = 'https://internalService/' + myWSXMLResult;
				update build;
			} 
			
		} 
		return myWSXMLResult;
	}
}

 

This is where the error is pointing to..

 

/******Error occurs on line below******/
build.Opportunity__r.LLURL__c = 'https://internalService/' + myWSXMLResult;

Im sure this is an easy one, thanks ahead of time for the advice.

  • May 07, 2012
  • Like
  • 0

Hello,

 

Im curious if there is tool similar to Toad or SQL Managment Studio for the SF data model? I want to run queries without having to export my results. I also want to be able to copy/paste values from my query results (such as ID's and other column values). I am unable to copy/paste the values from the Schema view in Eclipse. Im guessing thats to prevent editing the data. And I know I can find IDs in the URL, but would prefer retrieving the values through running a specific query.

 

Is there such a tool? All input is appreciated.

 

Edited: Just found SoqlXplorer by devangel, but that tool looks to be Mac only. 

 

 

Thanks ahead of time.

  • May 04, 2012
  • Like
  • 0

Hello all,

 

I could use some general assistance with a simple bit of Apex code. Just so you know I am a newbie to Salesforce.com, but not to web application programming (12 years but with Coldfusion and some Perl and am used to the MVC architecture), although I have not been exposed deeply to Java or C#.

 

So I am working on a simple controller that I'll use in a simple VF page. I'd just like to return the value and display it on the page but Im running into some syntax issues during compile. Here's my code so far:

 

Controller - mytest.cls

public with sharing class myTest {

	public class addNewFolder {
		
		String tmpFolderName = 'MyTestFolder';
		String tmpObjectID = '22K22'; 
		
		String tmpResult = 'Whoo-hoo!';
		System.debug('XIX|' + tmpResult);
		return tmpResult;
		
	}

}

Error

 

Description Resource Path Location Type
Save error: expecting a right parentheses, found 'XIX|' mytest.cls /PREPROD/src/classes line 15 Force.com save problem

 

 

  • April 30, 2012
  • Like
  • 0

Im new to Salesforce in general and Im trying to decide how to handle the invoking of a SOAP webservice. Currently the webservice is being executed via AJAX when a user clicks a button on the Opportunity page. I have been asked to move the webservice invocation from the button and place it into a custom controller page. So the webservice needs to be invoked seamlessly when certain conditions are met, opposed to having the user click a button.

 

I'd like to just kick off the webservice using the same ajax statement because it will save me time. Although it would seem to make more sense to invoke the webservice via Apex, but am still researching that topic.

 

So here is my question: Is it possible to execute the following javascript from within an Apex controller? If so how?

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
var xfolder = "MyNewFolder"
var parentid = "999999999999999"
var myvar = sforce.apex.execute("myWS","invokeExternalWs", {folderName:xfolder,ObjectID:parentid});
window.alert('Folder created: ' + myvar);

 

  • April 27, 2012
  • Like
  • 0

Hello,

 

I have generated a WSDL from a class I have created. I can see the generated XML in the browser, and everything looks fine, but I am having trouble consuming the webservice with the URL I am using to view the XML. I have changed the URL to server specific as well, but still having issues, so like this:

 

https://cs12.salesforce.com/services/wsdl/class/WS_TEST_WSDL

 

But the result just redirects me to the login screen. Status says OK though.

 

Here is my XML I am sending to the URL above:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://soap.sforce.com/schemas/class/WS_TEST_WSDL">
<soapenv:Header>

<ws:SessionHeader>
<ws:sessionId>my token value from the login goes here</ws:sessionId>
</ws:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<ws:DescribeFields/>
</soapenv:Body>
</soapenv:Envelope>

 

Does this look correct?  Since Im passing the SessionID I would assume there is no need to login again?

 

Also, I shouldn't need to setup any kind of Remote Access as I do with a REST API, is this a correct assumption as well?

 

All input is appreciated. Thanks!

 

  • April 23, 2012
  • Like
  • 0

Hello,

 

Im trying to consume a WSDL in our SFDC instance and am receiving the following response:

 

<!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"> <script> var escapedHash = ''; var url = 'https://test.salesforce.com/FAKEWSDLNAME'; if (window.location.hash) { escapedHash = '%23' + window.location.hash.slice(1); } if (window.location.replace){ window.location.replace(url + escapedHash); } else {; window.location.href = url + escapedHash; } </script> </head> </html> <!-- ................................................................................................... ................................................................................................... ................................................................................................... ................................................................................................... -->

 

Why does this happen and what do I need to do with it? 

 

All suggestions are appreciated.

 

Thanks ahead!

  • April 20, 2012
  • Like
  • 0