USD – Create Phone Call (Saved)

In an earlier post about Unified Service Desk (USD) for Microsoft Dynamics CRM 2016 I described how to create an agent script to open a phone call when a “Create Phone call” answer was selected. This approach was relatively easy to implement but had some limitations.

A few people have responded to that post as they have been “victim” to these limitations! The New_CRM_Page action I used allows a CRM page to be opened containing a phone call. With the related values set, such as from and regarding. But it was then difficult to default subject, description, direction and other fields on the phone call.

In the previous approach the phone call page was opened but the phone call wasn’t actually saved until the user decided they wanted to do that. Depending on your requirements this may or may not be viewed as a limitation.

In this post I will describe an alternative approach in which I create (a saved) phone call then load it in a tab. I have again done this from an agent script but you could also attach this logic into a toolbar or even use the concept as part of your CTI integration. Below you can see a screen shot of the agent script I have created for my contact with the new option highlighted.

When I select this option a new tab will open containing the newly created phone call. Notice that the subject, from, to and regarding fields have all been pre-populated. (You could also complete more fields if required!) Hopefully you can also tell from the ribbon bar options presented that this phone call has already been saved.

Agent Script

So the first thing you will need is an answer in an agent script. I’m going to assume that you know how to create agent scripts, mine is shown below.

Notice that I have highlighted my new answer. (The original I created in March is also shown!) Below you can see the content of that agent script answer. It essentially just has a name and the show tab is phone call.

On that phone call I have attached two actions. (One of which has sub actions.) You can see this below. The order here is important. As I want to create the phone call before I do “stuff” with it.

The first action creates the phone call, the second simply waits for the record for be available. Then a sub action is run to open the phone call in a tab.

Let’s look at the actions in a little more detail, starting with the create entity action.

Create Entity

As already mentioned my order was 10, as I wanted this to be the first action run. My hosted control is my global manager. And my action is CreateEntity.

The data field then contains the “code” to create my phone call.

The “code” I used is below. Hopefully you can see that I am setting various columns on the phone call to attributes from the contact. Importantly I can set any field in this manner.

Notice that for the to and from fields I am using the PartyList command. And also for the lookup of regarding I am using an EntityReference command.

subject=Call from : [[contact.fullname]]


You might not have come across this one before! Having fired the action to create my entity I need to wait (a short time) for the record to be saved before I can open it. ExecuteOnDataAvailable lets me do that.

Importantly its order is 20, as I want it to be fired after the create command. The hosted control of my global manager again and action is ExecuteOnDataAvailable.

Now my data field is important here! [[$Return.CRM Global Manage…..]], so what does that mean? Well $Return will contain the ID of the created field after the create entity action has finished. The name looks long but it is simply the name of the action of did my CreateEntity.

The ExecuteOnDataAvailable action may already exist as a uii action on your global manager hosted control. But don’t worry if it doesn’t simply add one!

What this does is nothing! At least nothing until the $Return replacement parameter returns an ID. Then it will fire the sub action(s) added to the ExecuteOnDataAvailable action. You can find these by looking in the actions navigation, as shown below.

Sub Action – Open Phone call

Now we add a simple action to open the phone call. See below that I have added one action. I have given it an order but as I’ve only added one action the order didn’t really matter!

The open phone call action looked like the one shown below. Notice my hosted control is the global manager, again. And that this time the action is Open_CRM_Page.

In my data field I enter the LogicalName of the entity I want to load. So in this example, phonecall. Then id is set to the ID of the field to open. This is the same $Return replacement parameter you used on the ExecuteOnDataAvailable action. Hopefully that now makes sense, as you can’t open the record until you have the id value available.

Window Navigation Rule

Everybody hates window navigation rules! (At least it seems that way to me.) The exact details you need here will differ depending on your specific solution.

The way I approached this was to run my solution BEFORE I added the rule. In the debugger I could then check that all of my actions were giving a success status. Plus, I could see that no existing rules were being triggered and also I saw that my phone call didn’t open.

  • Now we have just seen that the create entity action was run from my global manager. So my “from” field was set to the global manager.
  • The entity is obviously phonecall.
  • Running an Open_CRM_Page action will open the page as a pop up. So my route type is popup.
  • Destination is tab and action is route window. As that will add a tab into my session.

I guess I have also assumed you understand the USD concept of sessions.

Finally, I set the target and show tab fields to be my phone call tab.

Hopefully these instructions make sense! J

Sorry this isn’t the simplest USD change as it makes use of quite a few USD concepts. But take you time and you should be able to get this to work. Enjoy. J

10 thoughts on “USD – Create Phone Call (Saved)

  1. I want to be the first to thank you.

    It’s very helpfull and i just finished adapting it for my 2 cases.

    I’m in your debs mate.


  2. Pingback: USD – The Book | Microsoft Dynamics CRM and Unified Service Desk

  3. I have added 3 actions (1 is sub action as mentioned in this blog) to contact PageLoadComplete event, but I am having 2 issues
    Issue 1: creating the entity but not saving it.
    Issue 2: after loading the newly created phonecall record (which is not saved) both contact and phonecall record tabs are getting refreshed repeatedly (infinitely)

    Note: I have created ExecuteOnDataAvailable action on “CRM Global Manager” hosted control

    1. To create phonecall entity record (order is 10)
    2. executeondataavailable action to return ID of entity record created in previous action (order is 11)
    3. To open the saved (newly created one in previous actions) phonecall record (sub action to executeOn.. order is 12)

    I have also tried by having milliseconds=5000 in ExecuteOnDataAvailable action but no expected output.

    Any suggestions will be a great help…


    • Hi Pardeep

      Thanks for reading my blog and thanks for the message. Sorry for the slow response I have been away on holiday!

      I am not 100% about all of your issues. But it sounds like you are trying to achieve a slightly different outcome to what I described in my blog post. Rather than creating the phone call from an agent script are you trying to create it when the contact form loads?

      If so, your first “issue” will be that you have but the actions on PageLoadComplete event. This event is triggered several times when the contact form is loaded. Which would cause multiple calls to be created. Although you describe an infinite number which I wouldn’t expect!

      Try moving you actions to BrowserDocumentComplete event that will fire just once when the contact loads. That might help.

      When you say the record doesn’t get saved what do you mean? Are you seeing an error in the debugger on your CreateEntity action? If you manage to load the entity that is using its GUID which suggests the record is saved. Maybe it is blank or something?

      Hopefully this will help. Please experiment and come back to me with more questions if needed.

      Thanks again



  4. Thanks for the post sir.

    Had one question, Populating regarding lookup field using entity reference command gives error page while creating new phone call any suggestion on same?

    Steps done : –

    Creating phone call from agent script for lead.
    To associate phonecall to lead trying to update regarding field of phone call with lead ID.

    Below is entity reference command used : –


    Lead id is not passed null does have value crosschecked same.

    Creating phone call without updating regarding field works fine it only gives error on updating regarding field on phone call.

    Kindly provide some insight.


  5. Thanks for quick reply sir.

    Attaching data field in Action call created : –


    Hope it gives better insight.


    • I can’t see anything obvious!

      Although direction should be directioncode=Boolean(true) or (false). But that doesn’t sound like your issue.

      I just did a quick test in my application. I had only added the ability to create a phone call on contact. I have just added similar logic to lead and it worked find. I used …

      subject=Call from : [[lead.fullname]]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s