• doubleminus
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 59
    Replies

This seems to be a recent problem, but I can no longer select fields by checking the checkboxes in the shcema list view inside the eclipse ide.

 

Any ideas as to why this is or how to fix it? Reinstalling had no effect.

So, I'm one of many unable to get rerender functionality working successfully. The actual update to the boolean istrue works successfully but the rerender refuses to work. Very simple use case here.

 

I'm using Apex to perform some basic XML parsing. I'm having no luck getting to any of the actual XML node names. The getLocalName()  method within the XmlStreamReader class always returns null for all nodes as I loop through them.

 

TEST CLASS:

@isTest
private class BPTCalloutTest {
private static final String XML_STR = '<document>' +
'<result>success</result>' +
'<resultcode>000000</resultcode>' +
'<note></note>' +
                                        '<item>' +
      '<quantity>1</quantity>' +
  '<fname>Bob</fname>' +
  '<lname>Tungsten</lname>' +
  '<address>23232 Fleet Street</address>' +
  '<city>Santa Clara</city>' +
  '<state>CA</state>' +
  '<zip>94105</zip>' +
  '<country>United States</country>' +
  '<email>blahblahblah@blahblahblah.com</email>' +
  '<phone>4155555555</phone>' +
    '</item>' +
  '</document>';
 
    static testMethod void xmlStreamReaderTest() {
        XmlStreamReader reader = new XmlStreamReader(XML_STR);
        Opportunity[] opptyList = BPTCallout.parseXML(reader);
        System.assert(opptyList != null);
        System.assert(!opptyList.isEmpty());
    }
}

 

MAIN CLASS:

public with sharing class BPTCallout {
    public BPTCallout() {}

    public static Opportunity[] parseXML(XmlStreamReader reader) {
        Opportunity[] oppList = new List<Opportunity>();

        if (reader != null) {
            while (reader.hasNext()) {
            	System.debug('$$$ reader.getEventType(): ' + reader.getEventType());
                if (reader.getEventType() == XmlTag.END_DOCUMENT) {
                    break;
                }
                else if (reader.getEventType() == XmlTag.CHARACTERS) {
                	System.debug('$$$ reader.getLocalName(): ' + reader.getLocalName());
                	System.debug('$$$ reader.getText(): ' + reader.getText());
                	System.debug('$$$ reader.getNamespace(): ' + reader.getNamespace());
                	System.debug('$$$ reader.getlocation(): ' + reader.getlocation());
                	System.debug('$$$ reader.getprefix(): ' + reader.getprefix());
                	
                	if (/*reader.getLocalName() == 'lname'*/ reader.getAttributeCount() == 4 && reader.getText() != null) {
	                    oppList.add(new Opportunity(Name = reader.getText()));
                	}
                }
                reader.next();
            }
        }
        System.debug('$$$ oppList: ' + oppList);
        return oppList;
    }
}

 

Very basic functionality at this point. If you run this, you will see that reader.getLocalName() always returns null and so do all accompanying methods (getNameSpace, getLocation, getPrefix).

 

Thanks in advance.

 

I've seen some other threads around this subject, but the had a variety of issues being discussed and I'm hoping this one is more focused.

 

Am I missing something obvious? Here is my code:

 

@isTest
private class TestClassForIssue {
    public static Account testAccount1, testAccount2;

	static {
            testAccount1 = new Account(Name='testAccount1', NumberOfEmployees=10);
            insert testAccount1;
            System.assertNotEquals(testAccount1.Id, null);
	}

    static testMethod void test1() {
        System.assertNotEquals(testAccount1.Id, null);
}

 

The test1 testMethod assertion fails, saying that testAccount1.Id is null. Why is this? I'm sure I'm just missing something really obvious, but I'm not finding it...

Setup -> Develop -> Sites is not available on my DE org. Any ideas? I have System Administrator profile with every imaginable permission enabled on it and on my User record, including "Customize Application" and "Manager Users" perms.

 

Any ideas on how I can get access to Sites? The documentation says it should be available in Developer edition.

 

<script type="text/javascript">

   function enable()
   {
    if (document.getElementById("input").value.length > 0)
      document.getElementById("button").disabled = false;
    else
      document.getElementById("button").disabled = true;
   }
</script>


           <apex:inputField value="{!foo.bar__c}" id="input" onchange="enable()"/>

           <apex:commandButton action="{!save}" value="View" status="save" id="button" disabled="true"/>

 

That doesn't work at all. Any ideas? Seems like it should be super simple, so I may be missing something.

 

I basically just need a pageblocktable that has no header (it's just values, without the column titles) and has spacer columns in it. Is this possible? I've been unable to find a way to create empty columns.

 

And I get the feeling that using a datatable will be recommended. So, in that case, I still am unsure of how to have empty columns. Any ideas?

It seems like the val attribute of the pageblocktable tag only works with sobjects. I'm passing it a string array populated by an apex class, with 12 items, and no dice. The table won't populate.

 

Any suggestions?

 

Code looks like this:

                       <apex:pageBlockTable value="{!strings}" var="st">
                            <apex:column value="{!st}"/>
                       </apex:pageBlockTable>

Quick question. If want to perform an HttpRequest but need to pass multiple headers...how do I do that?

 

request.setHeader('API-KEY', APIKEY);
request.setHeader('ACCEPT', 'text/xml');

 

Does line 2 overwrite line 1?

Why doesn't this code work?

 

Class:

 

	public static void changeVal(String id) {
		Case cas = [select id, val_flag__c, Requisition_Number__c, debug__c from Case where id=:id];

		cas.Requisition_Number__c = '8888';
		
		System.debug(cas.Id + ' <--- ID of record being manipulated');
	}
}

 

 

Trigger:

 

trigger trigPull on Case (before update) {

    Case[] cases = Trigger.new;
    
    pullApprover.changeVal(Trigger.new[0].Id);

    System.debug(Trigger.new[0].Id + ' <--- ID of record being manipulated');
}

 

 

Nothing happens. The Requisition_Number__c field does not get updated.

 

I'm not just looking for a fix, I'm also looking to see why this doesn't work.

 

The System.debug statements return the correct IDs of the record I want to change...

So I'm trying to make a call out to a REST web service and am having a hard time. The end goal is that it will retrieve a string, and place it into a text field. Right now, I'm just trying to get the service to retrieve any basic information, as a starting point. And in the code, I'm trying to say: If you retrieve nothing...just update the field_debug__c field.

 

Next question, if I have multiple parameters to put into a header...how do I do that? For example, I need to provide an API key here, and an ACCEPT statement (=txt/xml). I'm sure setting twice, like I'm doing below, is wrong. How do I do this?

 

Apex class:

 

public class pullApprover {

    @future (callout=true)
    public static void restCallout(String id) {

      Case cas = [select id, val_flag__c, field_debug__c from Case where id=:id];

      HttpRequest req = new HttpRequest();

      //Set HTTPRequest params
      req.setMethod('GET');
      req.setEndpoint('https://rest.test.com/api/accounts/10');

      String APIKEY = '1234567';

      req.setHeader('X-API-KEY', APIKEY);
      req.setHeader('ACCEPT', '=text/xml');

      Http http = new Http();
      HTTPResponse res = http.send(req);
      System.debug(res.getBody());

      // Update case
     cas.field_debug__c = res.getBody();

 

 

And the trigger:

 

trigger dataPull on Case (after update) {

    Case[] cases = Trigger.new;

	pullName.restCallout(Trigger.new[0].Id);

	System.debug(Trigger.new[0].Id + '');
}

 

 

And I'm using that cas.field_debug__c to test if the case is even updating. It is not.

 

Any assistance is much appreciated.

 

double

Hi,

 

This may be a stupid question, but I'm having a hard time doing anything with the files generated by Axis2.

 

I made sure to use the xmlbeans databinding option when I generated them.

 

I ended up with a folder that had 2 subfolders (resources and src) and a build.xml file. Do I just place all of these in the project root? I've tried this and Eclipse freaks out and throws a bunch of errors, saying all of the class names are invalid, etc (even after cleaning the project).

 

I've also tried just placing the folders within src into the project src and that fails as well.

 

There is no mention of the specifics of this in documentation.

 

Thanks

Hi,

 

I'm having a hard time using the api example (http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content%2Fsforce_api_calls_create_saveresult.htm|SkinName=webhelp) to update Cases. The code doesn't seem to be the problem...the problem is getting access to the appropriate classes for using the SaveResult[] type. See code below.

 

 

List<SObject> cases = query("Select Id FROM Case WHERE Custon_Number__c = '" + num + "'");
case_ID = cases.get(0).getId();

Case[] updates = new Case[1]; // above SOQL call should only retrieve 1 case
Case updateCase = new Case();
updateCase.setId(case_ID);
updateCase.setCurrent_Approver__C("John Doe");
updates[0] = updateCase;

// Invoke the update call and save the results
try {
SaveResult[] saveResults = binding.update(updates[0]); // ***HERE IS THE PROBLEM*** SaveResult[] cannot be resolved
}
catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
return;
}

 

It looks like I need to use the com.salesforce.results package...(http://www.adnsandbox.com/media/flexsdk/docs/com/salesforce/results/package-detail.html)...but am unsure of how to do that. Any advice??

 

Also note, I'm using my own login and the enterprise.wsdl from a DE org where I have full admin permissions. Also, used latest 2.2.8 Apache CXF for wsdl2java, and all other parts of integration work fine.

 

The sample code from here does not work.

 

public boolean createAccountSample()
{
// Create two account objects
Account account1 = new Account();
Account account2 = new Account();

// Set some fields on the account object
// Name field (required) not being set on account1,
// so this record should fail during create.
account1.setAccountNumber("002DF99ELK9");
account1.setBillingCity("Wichita");
account1.setBillingCountry("US");
account1.setBillingState("KA");
account1.setBillingStreet("4322 Haystack Boulevard");
account1.setBillingPostalCode("87901");

// Set some fields on the account2 object
account2.setName("Golden Straw");
account2.setAccountNumber("003DF99ELK9");
account2.setBillingCity("Oakland");
account2.setBillingCountry("US");
account2.setBillingState("CA");
account2.setBillingStreet("666 Raiders Boulevard");
account2.setBillingPostalCode("97502");

// Create an array of SObjects to hold the accounts
SObject[] sObjects = new SObject[2];
// Add the accounts to the SObject array
sObjects[0] = account1;
sObjects[1] = account2;

// Invoke the create call
try {
SaveResult[] saveResults = binding.create(sObjects);

// Handle the results
for (int i=0; i<saveResults.length; i++) {
// Determine whether create succeeded or had errors
if (saveResults[i].isSuccess()) {
// No errors, so we will retrieve the id created for this index
System.out.println(saveResults[i].getId());
}
else {
// Handle the errors
System.out.println("Item " + i + " had an error updating.");
System.out.println("The error reported was: " +
saveResults[i].getErrors()[0].getMessage() + "\n");
}
}
} catch (InvalidSObjectFault e) {
System.out.println("Invalid object exception encountered:\n\n" + e.getMessage());
return false;
} catch (UnexpectedErrorFault e) {
System.out.println("Unexpected error exception encountered:\n\n" + e.getMessage());
return false;
} catch (InvalidIdFault e) {
System.out.println("Invalid Id exception encountered:\n\n" + e.getMessage());
return false;
} catch (RemoteException e) {
System.out.println("Remote exception encountered:\n\n" + e.getMessage());
return false;
}
return true;}

 

The problem is with the key piece: invoking the create call.

 

binding.create(sObjects);

 

I show the create() method as using a QName parameter, not an sObjects array parameter. Is there something I'm missing here? Please advise.

 

thx,

double

I want to lock all of the fields within a layout section if a picklist value is selected.

So for example, if you choose a picklist value "Purchased" instead of "Leased"...the "Lease Information" layout section becomes locked or otherwise uneditable.  Is this possible?  Any hints on the best way to go about this?

I mean I know it should just be a basic IF THEN statment  "IF acquisition_type__c == Leased THEN ..."

Not sure how to put this into Apex, or what the best approach is, for locking an entire section.  Or is there no way to lock an entire section in one foul swoop?

Thank you.

Nate
What would be the best strategy to include/obtain/developer a feature that includes placing a scan of a photo or paperwork into my app's layout? So upon creating a new case, there would be a file browser box to choose the image file...which, once attached, would be visible by default.

Validations would include only allowing .jpg, .png, etc., sizing constraints, and so on.

Is this possible?  What would be the best way to go about this?

Thanks so much!
I'm fairly new to this but trying to learn using the available documentation.  Hopefully this question is not too "large" to be answered on here.

My question:  After creating a custom object (let's call it "Asset" in this example), how can I make it so that when creating a new item (as in using the "Create New..." drop-down on the left pane of Salesforce), only a picklist is given...which then gives a layout depending on the option chosen from the picklist?

A walkthrough of what I'm trying to do:

1. User clicks on Create New... drop-down on left side

2. Choose "Asset"

3.  A picklist pops up with options for Asset Types (PC, monitor, printer)

4.  User chooses printer

5.  A layout is automatically given with fields specific for creating/tracking a printer

Any pointers/advice on how to do this?  Any help would be GREATLY appreciated.  Thanks!!

So, I'm one of many unable to get rerender functionality working successfully. The actual update to the boolean istrue works successfully but the rerender refuses to work. Very simple use case here.

 

I'm using Apex to perform some basic XML parsing. I'm having no luck getting to any of the actual XML node names. The getLocalName()  method within the XmlStreamReader class always returns null for all nodes as I loop through them.

 

TEST CLASS:

@isTest
private class BPTCalloutTest {
private static final String XML_STR = '<document>' +
'<result>success</result>' +
'<resultcode>000000</resultcode>' +
'<note></note>' +
                                        '<item>' +
      '<quantity>1</quantity>' +
  '<fname>Bob</fname>' +
  '<lname>Tungsten</lname>' +
  '<address>23232 Fleet Street</address>' +
  '<city>Santa Clara</city>' +
  '<state>CA</state>' +
  '<zip>94105</zip>' +
  '<country>United States</country>' +
  '<email>blahblahblah@blahblahblah.com</email>' +
  '<phone>4155555555</phone>' +
    '</item>' +
  '</document>';
 
    static testMethod void xmlStreamReaderTest() {
        XmlStreamReader reader = new XmlStreamReader(XML_STR);
        Opportunity[] opptyList = BPTCallout.parseXML(reader);
        System.assert(opptyList != null);
        System.assert(!opptyList.isEmpty());
    }
}

 

MAIN CLASS:

public with sharing class BPTCallout {
    public BPTCallout() {}

    public static Opportunity[] parseXML(XmlStreamReader reader) {
        Opportunity[] oppList = new List<Opportunity>();

        if (reader != null) {
            while (reader.hasNext()) {
            	System.debug('$$$ reader.getEventType(): ' + reader.getEventType());
                if (reader.getEventType() == XmlTag.END_DOCUMENT) {
                    break;
                }
                else if (reader.getEventType() == XmlTag.CHARACTERS) {
                	System.debug('$$$ reader.getLocalName(): ' + reader.getLocalName());
                	System.debug('$$$ reader.getText(): ' + reader.getText());
                	System.debug('$$$ reader.getNamespace(): ' + reader.getNamespace());
                	System.debug('$$$ reader.getlocation(): ' + reader.getlocation());
                	System.debug('$$$ reader.getprefix(): ' + reader.getprefix());
                	
                	if (/*reader.getLocalName() == 'lname'*/ reader.getAttributeCount() == 4 && reader.getText() != null) {
	                    oppList.add(new Opportunity(Name = reader.getText()));
                	}
                }
                reader.next();
            }
        }
        System.debug('$$$ oppList: ' + oppList);
        return oppList;
    }
}

 

Very basic functionality at this point. If you run this, you will see that reader.getLocalName() always returns null and so do all accompanying methods (getNameSpace, getLocation, getPrefix).

 

Thanks in advance.

 

Hello everyone,

 

We are trying to use the new API Salesforce made available during Winter '13: Test.setMock.

We followed the documentation, but encountered the following issue that we were unable to resolve: a System.CalloutException, complaining that we had "uncommitted work pending".

 

Of course we do, our testmethod starts by setting up some Test Data that's necessary for the test to work, and that includes inserting and updating data.

In an actual execution, there would be no data creation, as the data would already be present. Actually doing the callout doesn't raise the Uncomitted work pending exception, so the Test Data really is at fault.

 

We did use Test.startTest() and Test.stopTest() to differentiate Test Data creation from Test Execution but this (as expected) didn't work.

We also tried some hacks, including the System.runAs(new User( Id = UserInfo.getUserId()){} that had, in the past, allowed us to circumvent "Mixed DML operations". This didn't work either.

 

We considered using the Test.loadData method, but we're inserting related objects and couldn't figure out a clean enough way to make it work (maybe we should try using ExternalID's?).

 

 

For the moment, our workaround is to modify the class generated from the WSDL, adding a if (Test.isRunningTest()) {} else {}, but that means we have to modify the autogenerated code, which is suboptimal.

 

 

Did anyone try to use this new API and run into the same issue? How did you solve it?

I'm trying to enter a new pricebookentry into the standard price book (which is inactive), but I can't get any results querying for the Standard Price Book (planning on setting inactive to false) through the test class.  Here's the error I get:

 

System.QueryException: List has no rows for assignment to SObject

 

And here is the query:

PriceBook2 pbStd = [SELECT Id, IsActive FROM PriceBook2 WHERE Name = 'Standard Price Book'];

 

When I run the same query in the Force IDE I get the record.

 

Any thoughts?  


I've seen some other threads around this subject, but the had a variety of issues being discussed and I'm hoping this one is more focused.

 

Am I missing something obvious? Here is my code:

 

@isTest
private class TestClassForIssue {
    public static Account testAccount1, testAccount2;

	static {
            testAccount1 = new Account(Name='testAccount1', NumberOfEmployees=10);
            insert testAccount1;
            System.assertNotEquals(testAccount1.Id, null);
	}

    static testMethod void test1() {
        System.assertNotEquals(testAccount1.Id, null);
}

 

The test1 testMethod assertion fails, saying that testAccount1.Id is null. Why is this? I'm sure I'm just missing something really obvious, but I'm not finding it...

To test a visualforce page, we pass the record id to the page, as in,

 

https://c.na9.visual.force.com/apex/pages/AccountRecord?id=a00E0000002RzBR

 

I want to dynamically pass the record id so I created a class, however it's giving an error, can someone please help me correct my code. 

 

Visualforce Page

<apex:page standardController="Position__c" showHeader="false" >

<apex:form>
<apex:pageBlock >
    <apex:pageBlockSection >
    
    <apex:sectionHeader title="New Position Details" /> 
    </apex:pageBlockSection > <br/>
    
    <b>  &nbsp;&nbsp;
         <apex:OutputLabel value="Your approval has been requested for the following New Position."> 
         </apex:OutputLabel>
    </b>
      
   <br/> <br/>
    &nbsp;&nbsp;
    Position Record: {!Position__c.Name} <br/><br/>
   
    &nbsp;&nbsp;
    Status: {!Position__c.Status__c} <br/><br/>
   
    &nbsp;&nbsp;
    Location: {!Position__c.Location__c}<br/><br/>
    
    &nbsp;&nbsp;
    Functional Area: {!Position__c.Functional_Area__c}<br/><br/>
    
    &nbsp;&nbsp;
    Job Level: {!Position__c.Job_Level__c}<br/><br/>
    
    &nbsp;&nbsp;
    Minimum Salary: {!Position__c.Min_Pay__c}
    Maximum Salary: {!Position__c.Max_Pay__c}
    
    <br/><br/><br/><br/><br/><br/>
    
    &nbsp;&nbsp;&nbsp;
    
    <apex:OutputLabel value="Please Click the appropriate button below to approve or reject the request."> 
    </apex:OutputLabel> <br/><br/>
    
    &nbsp;&nbsp;&nbsp;
           
    <apex:commandButton action="{!saveAndReject}" styleClass="buttonStyle" style="vertical-align:left;width:80px;height:20px;background:green;" value="Approve" />        
    
    <apex:commandButton action="{!saveAndReject}" styleClass="buttonStyle" style="vertical-align:left;width:80px;height:20px;background:red;" value="Reject" />
              
    <br/><br/> 
   
</apex:pageBlock>
</apex:form>
</apex:page>

 extension controller

public class JobApp {

public Id posId       {get;set;}
private final Position__c pos;
public JobApp(ApexPages.StandardController controller)

{

 posId = controller.getRecord().Id;  
 
}
public PageReference saveAndReject() {

PageReference requestPage = Page.AccountRecord;
requestPage.getParameters().put(posId, Position__c.Id);
requestPage.setRedirect(true);
return requestPage;

}

}

 The above class gives an error -

 

 Error: Compile Error: Incompatible value type Schema.SObjectField for MAP<String,String> at line 15 column 29
  • January 23, 2012
  • Like
  • 0

Does anyone have any code that takes a custom user lookup field and changes the owner of the record to match and vice versa (changing owner updates user lookup field)?

 

I have a use case where I need to force the user to identify the owner of the record during the creation of the record and not rely on their memory to change the owner after the fact.

Hello,

     I have VF page where it displays the related cases upon selecting the case owner on top , the case owner drop down appears on left hand side of screen now i want to add the todays date on the right hand side? is it possible to add the date ?

 

This is what i have for case owner drop down now how to add date to the below?

 

<apex:pageBlockSection >
 <apex:inputField id="own" value="{!case.Case_Owner__c}"  onChange="getSelectedId('{!$Component.own}');"/>
 </apex:pageBlockSection>

 

 

TIA!

Hi,

 

I can easily dragged the text area field. How can i restrict user from dragging or stretching textarea??

 

Cheers,

Devendra S

 

<script type="text/javascript">

   function enable()
   {
    if (document.getElementById("input").value.length > 0)
      document.getElementById("button").disabled = false;
    else
      document.getElementById("button").disabled = true;
   }
</script>


           <apex:inputField value="{!foo.bar__c}" id="input" onchange="enable()"/>

           <apex:commandButton action="{!save}" value="View" status="save" id="button" disabled="true"/>

 

That doesn't work at all. Any ideas? Seems like it should be super simple, so I may be missing something.

 

It seems like the val attribute of the pageblocktable tag only works with sobjects. I'm passing it a string array populated by an apex class, with 12 items, and no dice. The table won't populate.

 

Any suggestions?

 

Code looks like this:

                       <apex:pageBlockTable value="{!strings}" var="st">
                            <apex:column value="{!st}"/>
                       </apex:pageBlockTable>

I have a very simple Batch class and I am trying to write a unit test to cover it but the execute method in this batch class is never executing. I'm stumped.

 

Batch Class:

global class ideaCleanBatch implements Database.Batchable<sObject>{

global Database.QueryLocator start(Database.BatchableContext bc){
//We want to process all Ideas
return Database.getQueryLocator('select Id from Idea');
}

global void execute(Database.BatchableContext bc, List<sObject> objects){
Set<Id> ideaIds = new Set<Id>();
for(sObject s : objects){
Idea i = (Idea)s;
ideaIds.add(i.Id);
}
//Send ideas to ideaClean for processing
ideaClean.recalcNumbers(ideaIds);
}

global void finish(Database.BatchableContext bc){
system.debug('All done.');
}
}

Test Method:

static testMethod void ideaBatchTest(){
List<Idea> ideas = new List<Idea>();
Id communityId = [select Id from Community limit 1].Id;
for(Integer i = 0; i < 200; i++){
ideas.add(new Idea(Title = 'myIdea' + i, CommunityId = communityId));
}
insert ideas;

Test.startTest();
ideaCleanBatch job = new ideaCleanBatch();
ID batchprocessid = Database.executeBatch(job);
Test.stopTest();
}

Coverage:

 

Thanks,

Jason

 

  • October 30, 2009
  • Like
  • 0