• GuyClairbois
  • NEWBIE
  • 205 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 6
    Questions
  • 126
    Replies

Hi

 

I'm trying to create a trigger that fires when a formula field is updated.

 

My question is whether a formula field updating automatically (without the user entering the record and editing or saving) constitutes an UPDATE event that could fire a trigger?

 

Thanks,

 

Paul

Hello

 

I'm trying to use an apex trigger to update the value of a picklist field on a related object. The trigger will execute when a custom object is inserted and then retrive a list of all the Tasks associated with the custom object.

 

I then want to change the 'Status' field (which is a picklist field) on the tasks.

 

Does anyone have any sample code for changing picklist field values in Apex?

 

Thank you.

I'm having trouble returning back to the correct page using the retURL parameter.  Here's the function from a customer controller extension that is triggered from a button on a VF page.
 
Code:
 public pagereference createInstall(){
  Service__c tempService = new Service__c();
  tempService.Account__c = this.myAsset.AccountId;
  tempService.Contact_1__c = this.myAsset.ContactId;
  tempService.Description__c = 'INST SO '+this.myAsset.Sales_Order__c;
  tempService.Classification__c = 'New Installation';
  tempService.RecordTypeId = '01230000000DMrlAAG';
  tempService.Start_Date__c = this.myAsset.Target_Ship__c+14;
  tempService.SO__c = this.myAsset.Sales_Order__c;
  tempService.PO__c = this.myAsset.Purchase_Order__c;
  tempService.Quote__c = this.myAsset.Quote__c;
  tempService.Stage__c = 'Not Shipped';
  insert tempService;
  
  
  Link__c tempLink = new Link__c();
  tempLink.Asset__c = this.myAsset.Id;
  tempLink.Service__c = tempService.Id;
  insert tempLink;
  
  PageReference editService = new PageReference('/'+tempService.Id+'/e?retUrl=https://cs2.salesforce.com/'+this.myAsset.Id);
  editService.setRedirect(true);
  return editService;
  
 }

 
This 1st chunk creates a new Service Record (custom object).  The second chunk inserts a record linking the new service to an Asset.  The final 3 lines call up the service edit page so the user can review the new record.  After saving (or cancelling) I would like the user to be returned back to the asset detail page.
 
Passing the retURL should take the user back to the Asset detail page (which is where this code is triggered from).  This is the only part of the code that fails.  The service record gets created just fine, the link gets created just fine, the Service Edit screen opens just fine but when the user clicks 'Save' on that screen they are returned to the SF home page instead of the asset detail screen.
 
I have tried both methods of including the full server address (https://cs2.salesforce.com/recordId) and also the partial method (/recordId).  Both methods return the user to the home page.
 
Anyone know what I'm doing wrong?
  • August 01, 2008
  • Like
  • 0
hi all,
 
i got an error message saying : request failed with http status 407: proxy authentication required(ISA server requires authorization to fulfill the request. access to the web proxy filter is denied )
whenever i try to run apex explorer.
 
what changes should i make into tools-> options to make it run properly?
 
thanks,
mahi
  • November 14, 2007
  • Like
  • 0

Hi all,

We built an interface to an external system using SOAP Callouts that trigger upon update on a certain object ('object1'). In order to successfully do the SOAP callout, we needed to put the callout in an @Future context, because callouts are only allowed from @Future classes.

 

This works fine, but....

 

We also have some processes in place that, whenever a certain other object ('object2') is updated, updates the matching object1. Since there can be a lot (thousands)  of matches, we also made this an @Future method. 

 

The problem, however, is that @Future methods cannot call @Future methods, so whenever object1 gets updated because of an update on object2, the export callout does not get triggered.

 

We've tried multiple solutions:

- using Outbound Messages instead. This is not an option since the object that gets exported also draws data from child objects when composing the SOAP message 

- I tried creating a static variable that checks whether an @Future method was already started, and proactively determines whether or not to run the callout as another @Future, but that doesn't help because the system tells me "Callout from triggers are currently not supported." (there is not @Future between the trigger on the object and the callout).

 

Any other suggestions? We'd want the interface to stay as 'online' as possible, so we will only try time-based workflow or batch apex if nothing else helps..

 

Many thanks!

Guy 

 

For who's interested: we (not Salesforce.com!) created an improved version of the Excel Addin with the following improvements:

 

1. Enhanced login-screen: easier switching between environments (less typing)
2. Validation rules are applied by default (by using newer api version)
3. Fixed error on duplicate columns (required custom fields were downloaded twice)
4. Removed default query on 'systemModeDate > [last 7 days]' if no filter criteria were filled in
5. Increased standard batch size from 50 to 200, improving upload performance
6. Removed checks on maximum amount of lines
7. Improved dates handling (sometimes downloaded dates would not upload back into salesforce again)

(update 2012-12-04, 2 more fixes)

8. ability to upload numberic fields as null instead of always 0

9. corrected the bug to cope with error when uploading numbers with many decimals. These were put into scientific notation in Excel but not loaded properly to SF

(update 2013-05-03, 1 fix)

10. ability to query more than 32766 rows (was hitting the VBA limit on Integer size)

 

Our users are very happy with it. Feel free to try it out or further build on it and let me know what you think:

http://code.google.com/p/improved-excel-addin/

 

Disclaimer: Though we made and tested all enhancements with great care, we take no responsibility for the consequences of the use of this tool. Also note that this is an open source tool and not maintained nor supported by Salesforce.com.

 

Regards,

Guy

Hi,

We are using the new bulk API for uploading large volumes of data with .NET Webrequests.

 

In order to improve performance, Salesforce recommends compressing the files that are sent to the systen. Does anybody know how to use compression in the outgoing webrequest? We would love to see some example .NET code, or e.g. the source code of the new DataLoader (v9), even java code would do.

 

Many thanks,

Guy

Hi all,

 

I have a custom object Deal with Deal_Location child objects. I created a custom button 'Replace Deal Locations' as a List Button on Deal_Location and placed this button in the Deal screen, located with the Deal_Location related list.

 

I created a custom VisualForce page that opens when the button is clicked, displaying the selected Deal_Locations for further processing. 

 

However, I'd like to do a quick check when a user clicks the button, on whether any Deal_Locations were actually checked. This can be done e.g. with the following Javascript:

 

var records = {!GETRECORDIDS($ObjectType.Deal_Location__c )};

if (records[0] == null) {
alert("Please select at least one Deal Location.") }
else {
window.parent.location.href='/apex/Deal_Location_Update';
}

 

The problem is that when I open the VisualForce page with the window.parent.location.href command, I loose the reference to the Deal_Location controller, so my VisualForce page has no idea of what Deal_Locations to show.

 

How can I solve this?

An option would be to only do the check in VisualForce, but this is a huge performance killer as it will load all the VisualForce code for nothing, and will also need a page reload for the original Deal page.

 

Many thanks in advance,

Guy

 

Message Edited by GuyClairbois on 10-07-2009 02:32 AM

I am creating a VF page on a standard controller. I'd like to create a button on the page that opens the new Record input screen (similar to the one on any tab home page). However, I can't find the correct action syntax for my commandButton.

 

Is this feature actually available for VF?

 

Many thanks,

Guy

Hi all,

 

I was wondering if there is an easy way to retrieve a list of changed fields from an update-trigger.

I mean without going through each and every field and checking whether if changed or not. I need this for an e-mail notification of the changes done on a custom object. Otherwise, whenever I add, remove or change a field, the trigger has to be updated.

 

Many thanks,

Guy

Before Summer 15, I used

 Account.IsPartner = true;

Sometime this approach ran into weird code exception. but It did work for most time.

Now in sandbox with Summer 15. the same code is broken.  it already runs into exception

System.SObjectException: Field is not writeable: Account.IsPartner 
Currently I am working on my DEV401 certification and as an excersise I tried making an IBAN validation rule. Since it actually works I thought I post it here. For some reason the rule editor didn't allow me to concatenate numbers so I had to convert them to text first and convert the result back to a number so I could MOD97 it. 
Suggestions for improvement of course are welcome.

MOD(
VALUE(
TEXT(CASE(MID(IBAN__c,5,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
TEXT(CASE(MID(IBAN__c,6,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
TEXT(CASE(MID(IBAN__c,7,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
TEXT(CASE(MID(IBAN__c,8,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
RIGHT(IBAN__c,
(CASE(LEFT(IBAN__c,2),
"AL",28,"AD",24,"AT",20,"AZ",28,"BE",16,"BH",22,"BA",20,"BR",29,"BG",22,
"CR",21,"HR",21,"CY",28,"CZ",24,"DK",18,"DO",28,"EE",20,"FO",18,"FI",18,
"FR",27,"GE",22,"DE",22,"GI",23,"GR",27,"GL",18,"GT",28,"HU",28,"IS",26,
"IE",22,"IL",23,"IT",27,"KZ",20,"KW",30,"LV",21,"LB",28,"LI",21,"LT",20,
"LU",20,"MK",19,"MT",31,"MR",27,"MU",30,"MC",27,"MD",24,"ME",22,"NL",18,
"NO",15,"PK",24,"PS",29,"PL",28,"PT",25,"RO",24,"SM",27,"SA",24,"RS",22,
"SK",24,"SI",19,"ES",24,"SE",24,"CH",21,"TN",24,"TR",26,"AE",23,"GB",22,
"VG",24,
8
)-8)
)
&
TEXT(CASE(MID(IBAN__c,1,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
TEXT(CASE(MID(IBAN__c,2,1),
"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,"G",16,"H",17,"I",18,"J",19,"K",20,"L",21,"M",22,"N",23,"O",24,"P",25,"Q",26,"R",27,"S",28,"T",29,"U",30,"V",31,"W",32,"X",33,"Y",34,"Z",35,8))
&
MID(IBAN__c,3,2)
)
,97
)
<> 1

I have a Pageblocktable which displays a set of values. Now each row in this table has a commandbutton whose action method will display another table below this pageblocktable.Now I want to highlight the row  whose commandbutton I clicked. Can somebody help me with this?

  • June 12, 2013
  • Like
  • 0

I am running in to an issue with generating apex code using a WSDL. The generated apex code does not seem to recognize the <xsd:extension> tage. Is this a known issue? 

 

Here is the WSDL snippet:

 

<xs:complexType name="Account">
<xs:complexContent>
<xs:extension base="snet:BaseObject">
<xs:sequence>
          <xs:element minOccurs="0" name="Reference" type="snet:AccountReference"/>
          <xs:element minOccurs="0" name="AccountName" nillable="true" type="xs:string"/>
           <xs:element minOccurs="0" name="AccountNote" nillable="true" type="xs:string"/>
           <xs:element minOccurs="0" name="Status" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

 

However, the generated Apex code, does not seem to extend the BaseObject.

 

 public class Account {
        public uriSubscribenetIntrawareCom.AccountReference Reference;
        public String AccountName;
        public String AccountNote;
        public String Status;
        public Boolean AccountNoteToNull;
        private String[] Reference_type_info = new String[]{'Reference','uri:subscribenet.intraware.com','AccountReference','0','1','false'};
        private String[] AccountName_type_info = new String[]{'AccountName','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] AccountNote_type_info = new String[]{'AccountNote','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] Status_type_info = new String[]{'Status','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'uri:subscribenet.intraware.com','true','false'};
        private String[] field_order_type_info = new String[]{'Reference','AccountName','AccountNote','Status'};
    }

 

Any ideas on how to get around this issue? 

  • January 21, 2013
  • Like
  • 0

I've been trying to use the Excel Connector for the last two weeks to manage the data in our organisation, but I'm having a problem where I get the following error in Excel which is preventing me from using this tool:

 

Error Generated by request::An internal server error has occured while processing your request.
Url:https://www.salesforce.com/services/Soap/c/13.0

ExceptionCode : 5103

The first couple of times I tried to use Excel Connector it worked fine. However I then started seeing this error every time I tried to use it - the error appears after I put in my password in Excel Connector and click Login.

 

We are on Salesforce Professional. I have tried uninstalling and reinstalling the toolkit and connector, but it hasn't made a difference. I'm using Excel 2010 32-bit on Windows 7 64-bit.

 

I can log in to Salesforce in my browser on the same computer.

 

I've checked that IE is not in Offline Mode, and verified that Excel can actually connect to the internet (pinged a URL using VBA script).

 

I've tried disabling my antivirus (MSE) and windows firewall.

 

I've tried changing the server url as suggested by this thread (had to modify registry keys to do this as that field was not editable in the connector.

 

None of these resolutions worked.

 

Has anyone experienced and managed to resolve this, or can anyone suggest any other possible resolutions?

I'm having trouble saving from eclipse, and receive following error:

 

Save error: Unable to perform save on all files: Destination URL not reset. The URL returned from login must be set in the SforceSerice

 

The thing is, I do not continuesly get it, it get it some hours, in a row, and then I don't anymore. Without changing any sf login settings. Sometimes it passes by by restarting eclips, sometimes it doesn't.

 

I've got running projects on different sf organizations, and sometimes i can't save to one because of this error, but have no trouble saving to another. Trying to look up the error, i mostly came across problems with API webservice connection problems, and no mentions of IDE problems.

 

Does anyone know what the issue might be, and how to fix/avoid it ?

In my component I use actionfunction and rerender

<apex:component controller="MultiSelectBoxController">
	...	
	<apex:panelGrid columns="4">
		...
		<apex:actionFunction name="moveDown" action="{!moveDown}" reRender="selectedRight"/> 
		
		...
	
	    <apex:selectList id="selectedRight" required="false" value="{!selectedRight}" multiselect="true" size="20" style="width:250px">
	        <apex:selectOptions value="{!rightOptions}"/> 
	    </apex:selectList>
	
	    <apex:panelGroup layout="block" style="text-align: center; padding:10px;">
	        Up<br/>
	        <a href="javascript&colon;moveUp();" style="text-decoration:none">
	            <img src="/s.gif" alt="Move Up" class="upArrowIcon" title="Move Up"/>
	        </a><br/>
	        ...
	    </apex:panelGroup>
	</apex:panelGrid>

</apex:component>

By debuging I am sure that my action method is called correctly

 

public class MultiSelectBoxController {

	...
	
	public PageReference moveDown() {
		// For each selected item right
		for(Integer r=0; r<selectedRight.size(); r++) {
			
			// Iterate over right list
			for(Integer pos=rightOptions.size()-2; pos >=0; pos--) {
				// When select item is found 
				if(rightOptions[pos].getValue() == selectedRight[r]) {
					// Save item above
					SelectOption tmp = rightOptions[pos+1];
					// Switch options with item above
					rightOptions[pos+1] = rightOptions[pos];
					rightOptions[pos] = tmp;
				}
			}
		} 
		return null; 
	}
}

 Even in Firebug I can see the AJAX POST request coming from the rerender. But on the page nothing happens although the rightOptions have changed...

 

After an hour of trial and error I hand this over to someone whos smarter than me....

 

Robert

Hello ,

 

I tried to push some objects and its fields from sandbox to production. But, after uploading the objects and thier dependent fields, the data has been uploaded successfully and i got mail from salesforce that, Your change set was uploaded successfully

 

Then when i look in to the production in Inbound Change Sets  there are no Change sets available for the deployment.

 

And i have pushed the data from sandbox many times, and every time i am getting the same problem as mentioned above.

 

So please anyone can help me or if any one faced the same problem. please let me know the solution.

 

Thanks & Regards,

Anirudh.

Hi,

 

Can someone suggest if there is any helptext kind of thing available in the Visual Force.

 

This is regarding the help icon which, when hovered by a mouse gives a help text explanation

 

which is present in the Standard objects & Custom Objects for the standard fields in them.

 

Is there a way of achieving this through javascript?

 

Please give me pointers in this issue. TIA.

Hey,
Getting some strange behaviour. I have a trigger that creates sharing rules when an object is created, so that customer portal users can see the object in their portal. Basically the object setup is "User" - "Contact" - "Membership Card". So anytime a membership card is created for a contact, a sharing rule is created so the user can see it via the portal.

This works fine if the new membership card is created by a standard user in SFDC.

However, the portal user has the abilty to create a membership card from a VisualForce page in the portal, and when they do the sharing rule trigger throws up the error: "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" on the line where i insert the sharing rule

However I thought that triggers run under the system account?

 

Any help is greatly appreciated

  • November 20, 2009
  • Like
  • 0

I'm trying to sign an XML document in one of my Apex classes.  Does Apex have any built in classes for signing XML documents?  Ie, like using the javax.xml.crypto.dsig.XMLSignature class or the Apache Santuario library?  I've looked at the Crypto.sign function, but I don't think it does what I need it to do (or if it does, please let me know!).

 

Thanks for any suggestions!

 

Kelly 

Hello, I have installed Excel connector and have not yet been able to import a report. I have chosen a variety of report types and report locations and get the same error message each time. Is there a setting I need to adjust? Thanks!

 

Error: Unable to retrieve the requested report. Please log in to Salesforce using a web browser to confirm the report's availability.
I am trying to create a Date of Birth field. Whether you are using a VF page or a regular page layout, when you use the calendar in Salesforce, it only lets you pick from years going forward. So the calendar is useless for something like a Date of Birth since obviously the year is before this year. Obviously the user can type the date, but is there any other way to adjust how the calendar behaves.
How do i resolve this...This is my code...I am sending an XML to an endpoint n number of times(its in a for loop)...Cant i do that?

public PageReference saveUsers() {
String[] listOfSelectedUsers = getUsers();
String domainId = System.currentPageReference().getParameters().get('ex');
for(String presentVar: listOfSelectedUsers)
{

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://84.40.30.147/cm/spws');
req.setMethod('POST');

TestExtranet__c extranet = [select Extranet_Name__c from TestExtranet__c where id = :domainId];
Lead lead = [select id,firstname,lastname,email from Lead where id = :presentVar];
String requestXML = buildXMLRequest('createUser',extranet.Extranet_Name__c,lead.id,lead.firstname,lead.lastname,lead.email);

req.setBody(requestXML);
HttpResponse res = h.send(req);
XmlStreamReader reader = res.getXmlStreamReader();
boolean errorExists = parseResponseForError(reader);
if(!errorExists)
{
Extranet_User_Mapping__c mapping = new Extranet_User_Mapping__c();
mapping.Extranet_Id__c = domainId;
mapping.Leads__c = presentVar;
insert mapping;
}else
{

}


}
PageReference userConfPage = new PageReference('/apex/userConfirmation?ex='+ System.currentPageReference().getParameters().get('ex'));
return Page.userConfirmation;
}


In a standard salesforce pages there is a way to filter/Sort the list based on staring Letter. This is precisely the requirement which was required to be built for custom visualforce page. I built a page and class which would do this functionality

 

click here to check the visualforce page and the controller to built the list

We are doing a massive upgrade of an org with a managed package. The package must be switched out with a new version (since managed packages can't be changed). Unfortunately we have about 200 custom fields on top of a managed package component. I can't seem to find the meta-data in the IDE. I know that there is a section for "Referenced Packages" which shows the schema of the packaged object only, no customizations. Also I can't see the customizations under src -> objects either. I would really like to copy and paste the XML and not recreate these 200 fields from scratch. Any ideas??

  • March 12, 2011
  • Like
  • 2