Here's what I'm trying to accomplish:

When a user is viewing or editing an opportunity they should have an "Export" button available to them. When they click this button a workflow is triggered which then sends out an outbound message.

From what I've found so far it sounds like there is no built-in way to do this. The best recommendation I've come across is to create a custom button and write some Apex to call the workflow... somehow.

I haven't been able to find any examples to go along with the recommendations I've come across. I would really appreciate any suggestions or other ways to accomplish what I need to do along with a small code sample.

I've been doing Salesforce development for less than a week and I've been reading as much documentation as possible. Needless to say I am very new at this.

  • I think there's an issue with terminology. This sounds like a task or "activity". Workflow only happens when a record has been inserted, updated or deleted. I highly recommend you spend time going through the Force.com workbook. – crmprogdev Mar 31 '15 at 19:11

You can write a javascript button that updates a field on the opportunity, and then have your workflow fire off that field. Let's assume you put a hidden checkbox on the opportunity called Hidden_Checkbox__c

Your button would look something like


var myquery = "SELECT Id, Name, Hidden_Checkbox__c FROM Opportunity WHERE Id = '{!Opportunity.Id}' limit 1"; 

result = sforce.connection.query(myquery); 
records = result.getArray("records"); 

var myOpp = records[0]; 
var updateOpp = new Array(); 

myOpp.Hidden_Checkbox__c = true; 

result = sforce.connection.update(updateOpp); 

    window.location = "/" + "{!Opportunity.Id}"; 
    alert('Could not Export : '+result); 

Then you just set up your Workflow to fire off the checkbox being set to true. (you might also want to set it to false as a field update as well)

  • I don't want to sound like I'm criticizing your answer because it looks like it will definitely do what I need. However, do you think there's a more elegant way to handle this type of thing in SF? Are most solutions to "non-standard" SF problems going to require something hacky? – Bruno Mar 31 '15 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.