• ryanhca
  • NEWBIE
  • 100 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 31
    Replies

Im receiving the following error when attempting to save the following VisualForce page.  Does anybody have any suggestions?  Im stumped.

 

Thanks in advance

 

 VF Page

 

 

<apex:page controller="editNewProjectExt" sidebar="false" showheader="false"> <apex:form > <apex:pageBlock title="Edit new project information" id="newproj" mode="edit"> <apex:pageBlockSection columns="2"> <apex:outputLabel value="Project Name"/> <apex:inputField value="{!myProject.Name}"/> <apex:outputLabel value="Account" /> <apex:inputField value="{!myProject.Account__c}" /> <apex:outputLabel value="Original Completion Date" for="OCDInput"/> <apex:inputField id="OCDInput" value="{!myProject.Original_Completion_Date__c}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!saveChanges}" value="Save" /> <apex:commandButton action="{!getupdCaseList}" value="Update Cases" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 Controller

 

public class editNewProjectExt{ Project_KA__c myProject; integer dayOffset = 0; date OCD=date.Today(); // Orginal completion date of new project date TCD=date.Today(); // Target completion date of new project, stores the user input from VF page on new orginal completion date List<Case> myCaseList; private final ApexPages.StandardController controller; public editNewProjectExt(ApexPages.StandardController controller){ this.controller = controller; myProject = (Project_KA__c)controller.getRecord(); myProject = [select Id, Name, Account__c, Target_Completion_Date__c, Original_Completion_Date__c from Project_KA__c where Id = :myProject.Id]; } // Getter public Project_KA__c getmyProject() { return myProject; } // Save method public pagereference saveChanges() { // myProject.Original_Completion_Date__c=OCDVF.Original_Completion_Date__c; update myProject; PageReference pageRef = new PageReference('/' + myProject.Id); pageRef.setRedirect(true); List<Case> myCaseList = getupdCaseList(); return pageRef; } // Calc new days public List<Case> getupdCaseList(){ if(myProject.Id<>Null){ myCaseList = [select Id, Date_Du__c, Internal_Date_Due__c from Case where Project__c = :myProject.Id]; // Set date veriables OCD= myProject.Original_Completion_Date__c; TCD= myProject.Target_Completion_Date__c; OCD=date.Today(); // loop through and update case details system.debug('OCD = '+OCD); system.debug('TCD = '+TCD); dayOffset = OCD.daysBetween(TCD); system.debug(dayOffset); for(Case myCaseListItem:myCaseList) { Case newCase = myCaseListItem; newCase.Date_Du__c = myCaseListItem.Date_Du__c + dayOffset; newCase.Internal_Date_Due__c = myCaseListItem.Internal_Date_Due__c + dayOffset; upsert newCase; } //for loop } // myClaseList select return null; // do not return anythign out of this method PageReference('/?id='+myProject.Id); } // getmyCalseList method } // For the class

 

 

 

 

 

 

 

I was wondering how we can leverage Apex to interact with a web service that requires session state (ie, cookies) to be preserved in order to issue further API calls.

 

I thought simply reusing the HTTP object would do this, but apparently not.  Here's what I have:

 

string endpoint = 'https://somesite.com/api'; string user = 'someuser'; string pwd = 'somepassword'; //set up the http object to be reused http ohttp = new http(); //set up the first request httprequest oReq1 = new httprequest(); oReq1.setendpoint(endpoint + 'login.aspx?user=' + user + '&pwd=' + pwd); oReq1.setmethod('GET'); httpresponse loginresponse = ohttp.send(oReq1); //set up the second request httprequest oReq2 = new httprequest(); oReq2.setendpoint(endpoint + 'secondapicall.aspx'); oReq2.setmethod('GET'); //this one fails because the session state is not preserved from the first call httprespons secondresponse = ohttp.send(oReq2);

 


 

 

We're only allowed to have 5 jobs in the queue for batch processing at a time. Ordinarily there's a method on the Limits class that allows us to get to info regarding limits, etc but I can't find one in this case. My money's on a bug in the documentation... Any help?

 

Current documentation: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm

I'm trying to catch the event of a new Customer Portal user being created.

 

I created a trigger on the User object:

 

 

trigger UserAfterInsert on User (after insert) { for (User u : Trigger.New) { System.debug('\n**** New User: contact ID: '+u.ContactId+'; IsPortalEnabled: '+u.IsPortalEnabled); } }

 

The output is:

 

**** New User: contact ID: 003S0000006mT5jIAE; IsPortalEnabled: false

 

isPortalEnabled is FALSE... If I query the database for this user after the trigger, isPortalEnabled is TRUE...

 

I imagine I could just look at the Profile Type, but I want to understand why this isn't working...

 

 

I have a page where I have two pageBlockSections that I want to toggle on and off... Here's the page:

 

 

<apex:page standardController="CustomObject__c" extensions="ControllerExt">

<apex:pageMessages id="pageMessages" />

<apex:form id="terminalForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockSectionItem >
<apex:outputLabel for="type">Type</apex:outputLabel>
<apex:selectList id="type" value="{!type}" size="1">
<apex:selectOptions value="{!typeOptions}" />
<apex:actionSupport event="onchange"
action="{!pageRefreshAction}"
rerender="TypeSection_CC,TypeSection_CH,pageMessages"
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:outputPanel id="TypeSection_CC" rendered="{!(type == 'option1'||type == 'option2')}">
<apex:pageBlockSection>
<!-- Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>

<apex:outputPanel id="TypeSection_CH" rendered="{!(type == 'option3')}">
<apex:pageBlockSection>
<!-- More Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

 

As you can see, the sections render depending on the value of "type". The default value of "type" is "option1". So "TypeSection_CC" is displayed when the page loads.

 

The "pageRefreshAction" method just adds a message to the page that displays the value of "type". I've tried making this method void as well, and it makes no difference.

 

 

public PageReference pageRefreshAction() { ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO, 'Type: '+type)); return null; }

 

 

When I choose "option3" from the "type" selectList the pageMessages block is refreshed and shows the value of "type" as "option3", but TypeSection_CC is still displayed and TypeSection_CH is not displayed.

 

Any help?? I don't know why this is causing problems...

 

Message Edited by ryanhca on 02-09-2010 11:55 AM

I need to batch process imported accounts and I can't do it through a trigger without hitting Governor limits so I'm trying to work out a way to push it into a batch job from the trigger, but I'm worried about the 5 batch job limit...

 

I believe the Data Loader loads data in batches of 200, meaning that if the customer imports 2,000 accounts, my trigger will be called 10 times with a Trigger.size of 200 each time. If I create a batch job every time the trigger is called, I'll have 10 batch jobs - creating an error.

 

Is there a way around that, or am I misunderstanding the process?

The documentation for the @future annotation says "No more than 200 method calls per Salesforce.com license per 24 hours".

 

I've seen this in the past, and after skimming, took away that the limit was 200 calls per [i]organization[/i]. Now that I need to use it and I read it more carefully, I understand that it's per [i]user[/i]. Is this correct?

 

Also, does this mean only 200 @future method calls per day [i]total[/i], or 200 per method per day? For instance, if I had two @future methods, could each of them be called 200 times per day, or is it 200 times total for both?

 

thanks.

We have a trigger on the Account object that's part of a managed package.

 

If an unlicensed user edits something on the account page, I'm getting a general System.Exception exception saying that an object doesn't have an 'Id' field... 

 

Wondering two things:

  1. Can I wrap all of the contents of my trigger in a try/catch statement to prevent this error, and
  2. Can I use a System.NoAccessException to catch this so that other exceptions are handled differently?

I'm planning on writing a process using Batch Apex to process new Account records. I see two ways to get data into the batch:

1) Pass the data in via a list (limit 1000 elements)

2) Use a QueryLocator

 

Also, I see that there's a limit of 5 concurrent batches.

 

I don't think the QueryLocator option applied in this situation because I can't write a static query that will capture all - and only - the accounts that were just imported. If there's more than 1000 records in the import, I'd have to pass them in using a second call to execute(), which would mean that I'd have another instance of the batch running. If I have over 5,000 records imported, I'd exceed the 5 batches...

 

It's *possible* to use a formula field or roll-up that I can use to identify the records I need to process, but that's not the cleanest solution. I can't imagine that the batch processing could only handle sets smaller than 5,000 records.

 

Can someone explain to me what I'm missing?

 

Thanks

I'm using the XmlStreamReader class to parse through an XML response from a REST service. One of the elements is a string and can contain entity references -- like "&amp;". So, if the element value is "this &amp; that", a reader.getText() will only return "this " because the entity reference constitutes a different event.

 

I can do a reader.next() and check to see if the event is an XmlTag.ENTITY_REFERENCE, but then how do I get at what the actual entity reference is and then translate that back to the real character?

 

Thanks.

I needed a way to shorten URLs I'm including in outgoing emails, so I wrote a quickie integration to bit.ly. Public domain... Hope it helps.

 

 

/*
Class to connect to bit.ly API to shorten a long URL
*/
global class bitly {
private static final String APIKEY = 'your_api_key';
private static final String LOGIN = 'your_bit.ly_login';


global static String shorten(String url) {
Http h = new Http();
HttpRequest request = new HttpRequest();
request.setEndPoint('http://api.bit.ly/shorten?version=2.0.1&format=xml&login='+LOGIN+'&apiKey='+APIKEY+'&longUrl='+EncodingUtil.urlEncode(url, 'UTF-8'));
request.setMethod('GET');

try {
HttpResponse response = h.send(request);

if (response.getStatusCode() == 200) {
XMLStreamReader reader = response.getXmlStreamReader();
String shortUrl = parseResponse(reader);
return shortUrl;
}
} catch (System.CalloutException e) {
System.debug('\n**** bit.ly CalloutException: '+e);
}

// if the callout was unsuccessful for any reason
return null;
}

private static String parseResponse(XmlStreamReader reader) {
String shortUrl;
while (reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT && reader.getLocalName() == 'shortUrl') {
reader.next();
shortUrl = reader.getText();
break;
}

if (reader.getEventType() == XmlTag.START_ELEMENT && reader.getLocalName() == 'errorMessage') {
reader.next();
if (reader.getEventType() != XmlTag.END_ELEMENT) {
String errorMessage = reader.getText();
System.debug('\n* Error message from bit.ly: '+errorMessage);
return null;
}
}
reader.next();
}

return shortUrl;
}

private static testMethod void testBitly0() {
bitly.shorten('http://www.salesforce.com/');
}

private static testMethod void testBitly1() {
String responseXml = '<bitly><errorCode>0</errorCode><errorMessage></errorMessage><results><nodeKeyVal><userHash>15pXjJ</userHash><shortKeywordUrl></shortKeywordUrl><hash>M2FqH</hash><nodeKey><![CDATA[http://www.salesforce.com]]></nodeKey><shortUrl>http://bit.ly/15pXjJ</shortUrl></nodeKeyVal></results><statusCode>OK</statusCode></bitly>';
XmlStreamReader reader = new XmlStreamReader(responseXml);
Test.startTest();
String shortUrl = parseResponse(reader);
System.assertNotEquals(null, shortUrl);
}

private static testMethod void testBitly2() {
String responseXml = '<bitly><errorCode>203</errorCode><errorMessage>You must be authenticated to access shorten</errorMessage><statusCode>ERROR</statusCode></bitly>';
XmlStreamReader reader = new XmlStreamReader(responseXml);
Test.startTest();
String shortUrl = parseResponse(reader);
System.assertEquals(null, shortUrl);
}
}

 

 

 

Message Edited by ryanhca on 10-13-2009 10:14 AM

On a standard SFDC page, user lookup fields have a drop down to the left of the input field where you can select "Standard User", "Partner User", etc (for examples, click the "Change Owner" link for any record). The drop down corresponds to the User.UserType field.

 

I have a VisualForce page where I have a user lookup <apex:inputField />. Of course, the UserType picklist isn't displayed for me, and when I search for a user, it's restricted to only Standard users. I need to be able to search and choose a Customer Portal user.

 

UPDATE

I just noticed that one of the URL parameters in the Lookup popup when I open it from my visualforce page is "lktp=StandardUserLookup". If I change the UserType picklist on the standard page to "Customer Portal", the parameter is "lktp=CustomerSuccessLookup". "CustomerSuccess" is the internal value for Customer Portal user types.

 

How can we change that parameter??

I have a field where we have the user enter the name of a pricebook. We need to validate that the name entered is a valid Pricebook Name. I'm trying to use the VLOOKUP function:

 

 

VLOOKUP( $ObjectType.Pricebook2.Fields.Name, $ObjectType.Pricebook2.Fields.Name, PricebookName__c )

 I don't really care what's returned -- I'll just make sure that something is returned.

 

 

  • September 15, 2009
  • Like
  • 0

I need to move data from one org to another org with the exact same config. I order to map Contacts to the right account (and other such parent-child relationships), do I need to set up external ID fields on each of those objects, or will DL figure that our for me (wishful thinking)?

 

Thanks

  • September 01, 2009
  • Like
  • 0

HI. I don't know if I'm doing something stupid or not, but I have two commandButtons calling methods in my controller extension and when I click them, they doesn't hit the method -- I don't see the debug statements in the code, and the logic in the method isn't run... All I see are the debug statements run for generating the page.

 

I'm using a StandardSetController on the page -- but even before that (I refactored the code to use a StandardSetController to see if it was something having to do with that...) the same thing was happening.

 

Any help would be appreciated. Here's the code (excerpts):

 

VF Page: (see "save" and "submit" buttons)

 

<apex:page standardController="Evaluator_Score__c" recordSetVar="EvaluatorScores" extensions="ApplicationEvaluationExt" showHeader="false" sidebar="false"> <apex:stylesheet value="{!$Resource.AppEvaluationStyles}" /> <apex:messages /> <script type="text/javascript"> function checkThis(elm, checked) { if (checked) elm.checked=true; } </script> <apex:form > <div id="header"> <div id="oppInfo"> <h3>{!FundingOpportunity.Name}</h3> <p>Evaluator: {!Evaluator.Name} ({!Evaluator.Id})</p> </div> </div> <ul id="sections"> <apex:repeat value="{!Sections}" var="s"> <li><apex:commandLink action="{!reloadSectionEvaluationForm}" reRender="sectionPanel" value="{!s.Section_Name__c}"> <apex:param name="secId" value="{!s.Id}" /> <apex:param name="appId" value="{!appId}" /> </apex:commandLink></li> </apex:repeat> </ul> <apex:pageBlock > <apex:pageBlockButtons rendered="{IF(Evaluation.Status__c=='Completed', false, true)}"> <apex:commandButton action="{!saveEvaluatorScores}" value="Save"> <apex:param name="mode" value="save" /> </apex:commandButton> <apex:commandButton action="{!submitEvaluation}" value="Submit Evaluation"> <apex:param name="mode" value="save" /> </apex:commandButton> </apex:pageBlockButtons> <!-- more code --> </apex:pageBlock> </apex:form> </apex:page>

 

 Custom Controller Extension:

public with sharing class ApplicationEvaluationExt { public PageReference saveEvaluatorScores() { System.debug('\n**** Application ID = '+appId); System.debug('\n**** EvaluatorScores = '+EvaluatorScores); // update EvaluatorScores; return new PageReference('/'); } public PageReference submitEvaluation() { saveEvaluatorScores(); Evaluation.Status__c = 'Completed'; update Evaluation; return new PageReference('/'+appId); } // more code ... }

 

Let me know if there's more code that you'd need to see.

 

Thanks!!!!!!!!!!!!

 

Is there any way to re-run an assignment rule on an existing lead or leads? Either Apex, API, Ajax, etc??

 

I tried the AssignmentRuleHeader in Apex and in the API through Ajax, but no dice.

 

I know the documentation says "The assignmentRuleHeader method specifies the assignment rule to be used when creating an account, case, or lead."... but I was hoping to get lucky.

I'm using a standard set controller to update multiple records displayed in a grid. I'm passing the IDs for the records to the VF page in the URL in one parameter, comma separated. in the setController property, I'm pulling out those IDs, querying the database, then returning the related records.

 

The problem is that when I try to save the records, they're not changing. 

 

I can see what's happening -- when my save() method gets the records to update from the setController, it's going through the same routine to pull the records from the database. Of course, that's not what I want.

 

I tested, and if (after the page is rendered), I comment out the database logic in the setController, the setController only has the updated records and the save performs correctly.

 

For now, I've written a clugy work-around that checks to see if the number of records in the setController are the same as the number of IDs I've passed to the page. If there's more, I know that I'm rendering the visualforce page -- if they're the same, I *assume* that I'm trying to save the records - and I bypass the database logic. But this is prone to bugs...

 

Here's the code. Any hints on a better approach would be appreciated.

 

 

public ApexPages.StandardSetController setController { get { String[] shipmentIds = EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('Ids'), 'UTF-8').split(','); if (setController.getRecords().size() > shipmentIds.size()) { String query = 'Select Id, Name, Status__c, SalesOrder__c From Shipment__c Where '; for (String id : shipmentIds) { query += 'Id = \'' + id + '\' Or '; } query = query.substring(0, query.length()-4); List<Shipment__c> shipments = new List<Shipment__c>(); try { shipments = Database.query(query); } catch (System.Queryexception e) {} setController = new ApexPages.StandardSetController(shipments); } return setController; } set; }

 

 

 

I have a simple JSON string that I'm trying to parse using the open source JSONObject class from the code share.

 

Here's the string:

 

 

{"items":[{"name":"widget 1","productCode":"w1", "price":5,"units":1}], "subtotal":5, "total":8.56, "salesTax":3.56, "shippingCharge":0, "shipping":6}

 

 To parse this, I'm simply doing:

 

 

JSONObject json = new JSONObject(decoded);

 

Where "decoded" is the JSON string.

 

The I'm getting a TypeException with the message: "Invalid integer: 8.56"

 

Obviously, it's not an integer -- how can this be parsed as a double?

 

After trying to execute the "webServiceName" web service below, I get this error:

ERROR: ........... {faultcode:'soapenv:Client', faultstring:'No service available for class 'MyClass'', }

 

Here's my button code:

 

{!requireScript("/soap/ajax/16.0/connection.js")}
{!requireScript("/soap/ajax/16.0/apex.js")}

var args = {
objId:'{!MasterObject__c.Id}',
childIds:{!GETRECORDIDS($ObjectType.ChildObject__c)}
};

function callback(result) { location.href=result.pagereference; }

var result = sforce.apex.execute('MyClass', 'webServiceName', args, callback);

 

 

 

Here's my service code:

 

global with sharing class MyClass
webservice static wsResult webServiceName(String objId, String[] childIds) {
// Do stuff...

wsResult result = new wsResult();
result.pagereference = pr.getUrl();
result.success = true;
result.errorCode = 0;
result.errorMsg = '';
return result;
}

global class wsResult {
webservice string pagereference;
webservice boolean success;
webservice Integer errorCode;
webservice String errorMsg;

public wsResult() {}

public wsResult(string url, boolean result, Integer code, String msg) {
this.pagereference = url;
this.success = result;
this.errorCode = code;
this.errorMsg = msg;
}
}

 

 I looked in my Enterprise WSDL, and couldn't find my service -- but I'm a complete novice with WSDLs...

 

 

 Thanks in advance!

I have a user operation that creates a series of child records against a master record.

 

After a user operation completes, I want to send them back to the page for the master record and down the page to the related list for the child records. ... It's just a nicer user experience...

 

I notice that when I click the related list title in the header of the page, the URL is:

https://na6.salesforce.com/a0I800000047wms#a0I800000047wms_00N80000003aRvw_target

 

where 'a0I800000047wms' is the ID for the master object, and '00N80000003aRvw' is the field id for the foreign key of the field on the child object pointing back to the master object. So if I just go to https://na6.salesforce.com/00N80000003aRvw, I'm taken to the field properties for that field.

 

If I could dynamically pull that field ID given an sObject or sObjectField, I could do this -- but I can't seem to figure out a way to find it. I've tried CustomObject__c.SObjectType.getDescribe().getChildRelationships() and running getField().getDescribe() on each of the child relationship records, but nothing...

 

Any ideas?

I haven't worked with the Apex Batch capabilities yet... it looks like the batch size is set to 200. However, some limits are lower than that -- such as the number of callouts allowed in a transaction (10). Is it possible to change the batch size to a lower number?

 

Basically, I need to run through all of the records of a particular object that meet the criteria, and for each, call an external web service (callout) and update the record accordingly.

 

And incidentally, it seems that the query/callout logic and the update logic would have to -- or could -- use different batch limits.

Are triggers synchronous or asynchronous?

 

If I make an "insert" call in an Apex method, and that insert triggers a "before" and/or an "after" trigger for that record, should I expect that those triggers complete before the next line of Apex code?

 

I think the answer is "no" - meaning that triggers are asynchronous, but I just wanted to check...

How do I pull out a field ID? 

 

E.g;  a checkbox will have something like  "a0A70000007O2Ap"  or something along those lines. How do I find these?

Hi,

 

I need to create Apex code that manipulates over 200 records. Where can I find instructions on how to do this as simply as possible. I am aware that once can work with a SOQL query in a loop, which allows you to breat the 200 Barrier for one of the objects, but if you have to work with several sets of objects, it becomes difficult.

 

I would appreciate any sources of info.

 

Thanks

 

Ben 

  • February 15, 2010
  • Like
  • 0
I have two workspaces in Eclipse.  One for production (linked to a production version of  salesforce.com) and one for development (linked to a development edition of salesforce.com).  The production one returns details of the execution including the system.debug ouput.  The log level in production is set to Debug.  If I run the same code in the development environment it only returns 'Anonymous execution was successful' no matter what setting you use for the log level.

Hello all

 

my situation is:

 

i have two account record types:

parent

child

 

certain fields exist and are relevant for both record types.

these fields should be synchronized between parent and child.

 

so far so good.

 

the problem starts here:

if one of these fields was updated (manually - not via trigger) in the child,

i should not sync that field from the parent ever again.

 

how can i know if such an event occured (manual change) ?

 

thanks

ndgani 

  • February 15, 2010
  • Like
  • 0
I have a page where I have two pageBlockSections that I want to toggle on and off... Here's the page:

 

 

<apex:page standardController="CustomObject__c" extensions="ControllerExt">

<apex:pageMessages id="pageMessages" />

<apex:form id="terminalForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockSectionItem >
<apex:outputLabel for="type">Type</apex:outputLabel>
<apex:selectList id="type" value="{!type}" size="1">
<apex:selectOptions value="{!typeOptions}" />
<apex:actionSupport event="onchange"
action="{!pageRefreshAction}"
rerender="TypeSection_CC,TypeSection_CH,pageMessages"
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:outputPanel id="TypeSection_CC" rendered="{!(type == 'option1'||type == 'option2')}">
<apex:pageBlockSection>
<!-- Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>

<apex:outputPanel id="TypeSection_CH" rendered="{!(type == 'option3')}">
<apex:pageBlockSection>
<!-- More Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

 

As you can see, the sections render depending on the value of "type". The default value of "type" is "option1". So "TypeSection_CC" is displayed when the page loads.

 

The "pageRefreshAction" method just adds a message to the page that displays the value of "type". I've tried making this method void as well, and it makes no difference.

 

 

public PageReference pageRefreshAction() { ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO, 'Type: '+type)); return null; }

 

 

When I choose "option3" from the "type" selectList the pageMessages block is refreshed and shows the value of "type" as "option3", but TypeSection_CC is still displayed and TypeSection_CH is not displayed.

 

Any help?? I don't know why this is causing problems...

 

Message Edited by ryanhca on 02-09-2010 11:55 AM

There is a special contact email edit screen that only appears in certain circumstances. For example, in a salesforce send email screen, you try to send an email to a contact ("To:") that has no email address on its record and then click on the link that appears below the error message, enter the email on the edit screen, and hit one of the save buttons.  I'm told it also may appear in certain bounced email situations.

 

This edit screen apparently bypasses the After Update Trigger on Contact!  As you might imagine, a contact record being updated without a contact record update trigger being fired might be a problem.

 

Could I get confirmation that others are experiencing this same behavior on their org and agreement that indeed contact edit screens even special one-field edit screens should always fire an after update trigger when saving the record and therefore it's a bug?

 

Getting SalesForce support to admit to a bug in my experiences is always like pulling teeth.  When they say it isn't a bug, I'd like to be able to say the developer forums agree that after update triggers should fire when a record is updated.  When they say it's my fault, I'd also like to be able to say we agree that since the trigger isn't being executed at all in those circumstances, it can't be an Apex coding error in my trigger.

 

We have a trigger on the Account object that's part of a managed package.

 

If an unlicensed user edits something on the account page, I'm getting a general System.Exception exception saying that an object doesn't have an 'Id' field... 

 

Wondering two things:

  1. Can I wrap all of the contents of my trigger in a try/catch statement to prevent this error, and
  2. Can I use a System.NoAccessException to catch this so that other exceptions are handled differently?

I'm planning on writing a process using Batch Apex to process new Account records. I see two ways to get data into the batch:

1) Pass the data in via a list (limit 1000 elements)

2) Use a QueryLocator

 

Also, I see that there's a limit of 5 concurrent batches.

 

I don't think the QueryLocator option applied in this situation because I can't write a static query that will capture all - and only - the accounts that were just imported. If there's more than 1000 records in the import, I'd have to pass them in using a second call to execute(), which would mean that I'd have another instance of the batch running. If I have over 5,000 records imported, I'd exceed the 5 batches...

 

It's *possible* to use a formula field or roll-up that I can use to identify the records I need to process, but that's not the cleanest solution. I can't imagine that the batch processing could only handle sets smaller than 5,000 records.

 

Can someone explain to me what I'm missing?

 

Thanks

I'm using the XmlStreamReader class to parse through an XML response from a REST service. One of the elements is a string and can contain entity references -- like "&amp;". So, if the element value is "this &amp; that", a reader.getText() will only return "this " because the entity reference constitutes a different event.

 

I can do a reader.next() and check to see if the event is an XmlTag.ENTITY_REFERENCE, but then how do I get at what the actual entity reference is and then translate that back to the real character?

 

Thanks.

Is there any way to re-run an assignment rule on an existing lead or leads? Either Apex, API, Ajax, etc??

 

I tried the AssignmentRuleHeader in Apex and in the API through Ajax, but no dice.

 

I know the documentation says "The assignmentRuleHeader method specifies the assignment rule to be used when creating an account, case, or lead."... but I was hoping to get lucky.

I'm using a standard set controller to update multiple records displayed in a grid. I'm passing the IDs for the records to the VF page in the URL in one parameter, comma separated. in the setController property, I'm pulling out those IDs, querying the database, then returning the related records.

 

The problem is that when I try to save the records, they're not changing. 

 

I can see what's happening -- when my save() method gets the records to update from the setController, it's going through the same routine to pull the records from the database. Of course, that's not what I want.

 

I tested, and if (after the page is rendered), I comment out the database logic in the setController, the setController only has the updated records and the save performs correctly.

 

For now, I've written a clugy work-around that checks to see if the number of records in the setController are the same as the number of IDs I've passed to the page. If there's more, I know that I'm rendering the visualforce page -- if they're the same, I *assume* that I'm trying to save the records - and I bypass the database logic. But this is prone to bugs...

 

Here's the code. Any hints on a better approach would be appreciated.

 

 

public ApexPages.StandardSetController setController { get { String[] shipmentIds = EncodingUtil.urlDecode(ApexPages.currentPage().getParameters().get('Ids'), 'UTF-8').split(','); if (setController.getRecords().size() > shipmentIds.size()) { String query = 'Select Id, Name, Status__c, SalesOrder__c From Shipment__c Where '; for (String id : shipmentIds) { query += 'Id = \'' + id + '\' Or '; } query = query.substring(0, query.length()-4); List<Shipment__c> shipments = new List<Shipment__c>(); try { shipments = Database.query(query); } catch (System.Queryexception e) {} setController = new ApexPages.StandardSetController(shipments); } return setController; } set; }

 

 

 

Im working with the code found here for the google maps API. I successfully got the geocoding to work but when i run the page given to show the map, I get a blank error message and the map doesnt render.

Heres the page code just in case...

 

<apex:page sidebar="false" controller="GoogleMapController"> <c:GoogleMap mapType="normal" mapkey="{!forcekey}" data="{!geoDataTable}"/> </apex:page>

 

 

 

Hi,

 

I have following design in my vf page.

 

Salesforce tab => Tab Panels => Tab = > Panel Bar => Panel Bar items

I have used apex components inside the panel bar items.

 

When I want action on particular Tab/panel I do not want other getter setters to be invoked. because after some time it gives me  Too many SOQL queries : 101 error

 

When I am changing the request e.g. from url//<!--VF page-->?studentId=1 to url//<!--VF page-->?studentId=1 this error is coming.

So how should I avoid this. Or do I need to chnage whole design. I do not want getter setter from other panels to be invoked each time.

So what can be the solution. Is there a way to invoke only selected component in a panelbar on some event. 

 

Thanks..

 

  • August 13, 2009
  • Like
  • 0

After trying to execute the "webServiceName" web service below, I get this error:

ERROR: ........... {faultcode:'soapenv:Client', faultstring:'No service available for class 'MyClass'', }

 

Here's my button code:

 

{!requireScript("/soap/ajax/16.0/connection.js")}
{!requireScript("/soap/ajax/16.0/apex.js")}

var args = {
objId:'{!MasterObject__c.Id}',
childIds:{!GETRECORDIDS($ObjectType.ChildObject__c)}
};

function callback(result) { location.href=result.pagereference; }

var result = sforce.apex.execute('MyClass', 'webServiceName', args, callback);

 

 

 

Here's my service code:

 

global with sharing class MyClass
webservice static wsResult webServiceName(String objId, String[] childIds) {
// Do stuff...

wsResult result = new wsResult();
result.pagereference = pr.getUrl();
result.success = true;
result.errorCode = 0;
result.errorMsg = '';
return result;
}

global class wsResult {
webservice string pagereference;
webservice boolean success;
webservice Integer errorCode;
webservice String errorMsg;

public wsResult() {}

public wsResult(string url, boolean result, Integer code, String msg) {
this.pagereference = url;
this.success = result;
this.errorCode = code;
this.errorMsg = msg;
}
}

 

 I looked in my Enterprise WSDL, and couldn't find my service -- but I'm a complete novice with WSDLs...

 

 

 Thanks in advance!

I have a user operation that creates a series of child records against a master record.

 

After a user operation completes, I want to send them back to the page for the master record and down the page to the related list for the child records. ... It's just a nicer user experience...

 

I notice that when I click the related list title in the header of the page, the URL is:

https://na6.salesforce.com/a0I800000047wms#a0I800000047wms_00N80000003aRvw_target

 

where 'a0I800000047wms' is the ID for the master object, and '00N80000003aRvw' is the field id for the foreign key of the field on the child object pointing back to the master object. So if I just go to https://na6.salesforce.com/00N80000003aRvw, I'm taken to the field properties for that field.

 

If I could dynamically pull that field ID given an sObject or sObjectField, I could do this -- but I can't seem to figure out a way to find it. I've tried CustomObject__c.SObjectType.getDescribe().getChildRelationships() and running getField().getDescribe() on each of the child relationship records, but nothing...

 

Any ideas?

I just realized you can't create a trigger on PricebookEntry. I need to be able to watch for changes to prices -- how can I do that?

 Hello all. I've got a pageblockTable that is generated from a list, and I'd like to be able to style rows on-the-fly. The sensible thing to do seemed to be to build up a string of class names while iterating through the list (in Apex), then to spit out that string like so:

 

 

<apex:pageblockTable value="{!master}" var="m" rowClasses="{!masterRowClasses}">

 

Alas, this doesn't work. There's nothing wrong with the string that's generated by the Apex, as it'll work fine when pasted in place of the formula reference. The doco isn't explicit on the subject, so I'm left wondering if this can be done.

 

Anyone ever done this or something similar? If not, anyone care to have a go?

Thanks! :)

 

any reason why the assignment rules won't trigger for new cases in this trigger:

 

trigger WebCaseAssign on Case (before insert) {
    integer i = 0;

    for (Case theCase:trigger.new) {
        if(theCase.Origin == 'Web') {
            Database.DMLOptions dmo = new Database.DMLOptions();
            dmo.assignmentRuleHeader.useDefaultRule = true;
            theCase.setOptions(dmo);   
        }
       
    i++;       
    }
   
}

 

I assume it's related to this issue/bug with Salesforce:

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=10690

Message Edited by jduhls on 04-22-2009 11:31 AM
  • April 22, 2009
  • Like
  • 0