Calling External URL from Workflow

By | May 24, 2013

Hello folks! Here we are back with one more interesting trick. Some days ago I came across this question on Sage development partner’s forum. Thought I could modify the suggestion with screens and add it over here. Here is the scenario posted by user.

 Scenario:

I have a customer who wants to call an external URL from a workflow action passing in some query string parameters. I created a new workflow action which calls a custom asp page.  This custom asp page uses javascript to call window.open which opens up the external URL in a separate window.  I then update the oppo record’s stage as well as the work flow instance’s currentstateid.  All of this works great, but I have 2 issues.  One, the workflow history doesn’t get created when I change the workflow instance.  I guess I should have expected that, but I was curious as to how I would create the workflowhistory.  I can call the CreateRecord method and save it, but I’m not sure what the TransitionId should be.  Not sure where that value comes from.  The other problem is, once I close out of the new window that popped up and I go back to the crm screen it shows a blank screen.  I tried using Response.Redirect to take me back to the Oppo Summary screen but when I do that it never pops up the new window.  Does anyone have any suggestions on how to handle this?  It would be nice to be able to pop up the new window and when I go back to the crm screen show the workflow progress window which would allow the user to put in a tracking note and advance the worfklow state.  Is that possible?  How do you call up the workflow progress screen?  Thanks.
What can be done?
Requirement is to open Opportunity Workflow Progress screen as well as open a page in Popup window as shown below.

Clicking on Queue button will open below screen and say google.com in popup window.

Here are the steps you can follow.
1) Log in to Sage CRM
2) Go to Administration | Customization | Secondary Entity | Opportunity Progress  | Screen
3) Create New Opportunity workflow Progress Screen by clicking on New button
4) Add Required column in above mentioned screen
5) Go to Administration | Advanced Customization | Workflows | Opportunity Workflow
6) Click on Edit workflow button
7) Click on <Workflow Rule > button
8) Enter Custom Asp Page path in Custom File Name field
9) Click on save button
10)Click on Activate Workflow button
11) Open Custom Asp Page file into Notepad or Notepad++
12) Write a JavaScript code to open <External URL Page> on Page Load.
13) Using eWare.GetBlock (<Screen Name>) method call
(Opportunity workflow Progress , Opportunity Progress Note Box) on screen
14) After clicking on Save button kindly follow the below given steps
a.Create new record into Opportunity Progress entity
b.Handle Workflow Progress entry
i. Fetch Opportunity Workflow id from Workflow Entity
ii.Based on Workflow id fetch Workflow State id from Workflow  State entity
iii.Based on Workflow Id and State id fetch  Top 1 Workflow Transition id
from  vWorkflowTransition view
iv. Add new entry into Workflow Instance entity
v. Add new entry into Workflow History entity
vi.Update new Workflow Instance id into Opportunity
Workflow id field
c.Navigate user to Opportunity Summary Screen