USD – Agent Script to create an entity

In an earlier post I explained what can be done with agent scripts, I then followed up with a description on how to create an agent script.

Now lets look at one of the most useful customizes you can achieve with agent scripts. Having found an account it maybe useful to have the ability to create a new case, phone call, order etc. But when creating these new records you’ll probably want to carry forward information about the account to the new entities.

In this post I will explain how to do this.

As always, I’m going to use my fishing sample application to help explain. (sorry!) In my example I would like the ability to create a record to log details of my trips to lakes. So having viewed a lake I need an agent script that will allow me to create a trip to that lake. In the real world creating a case for an account and such like might be more typical. But the logic / approach remains the same.

The steps involved are ….

  1. Create a hosted control for new record.
  2. Create an answer to create entity.
  3. Create an action to create the new entity.

Step One – Create a hosted control for new record.

First of all you’ll need to create a new hosted control that will contain the new entity, so in my example I have created this control for a new fishing trip.

Notice how I have given the display name the value “New Trip([[new_fishinglake.new_name]])”, I’ve done this as the new trip won’t yet exist so I can’t use its name. But I can reference the name of the source entity. If you were creating a case for an account, for example, you mighte use something like “New Case([[account.name]])”.

Agent Script - Add 1

Step Two – Create an answer to create entity.

I’ll assume you know how to create an agent script at this point! If not refer to the earlier posts I mentioned in my introduction.

Below you can see I have created an answer called Create Trip.

Agent Script - Add 2

My create trip answer is shown below. Some things to notice include;

  1. The answer text is how the operator will see this answer described on their screens.
  2. The order of 1 suggested I want to see this as the top answer.
  3. Show tab is the hosted control I created in step one, doing this will give the new tab focus having clicked on this answer.
  4. The enable condition and visible condition are set to [[new.fishinglake.new_name]], I’ve done this as this option will not be presented to the operator until the lake has been saved. You wouldn’t, for example, want to allow creating cases until the required account or contact had been created.

Agent Script - Add 3

Step Three – Create an action to create the new entity.

Now you have an agent script with an answer to create the new trip (or anything) you’ll need to add an action to the answer to create the new entity. Below you can see I have created an action call that will create my trip.

Agent Script - Add 4

My action is shown below. A few things to note ….

  1. The hosted control has been set to the one created in step one.
  2. The action is “New_CRM_Page”.
  3. The data section is important. The top line “LogicalName=new_fishingtrip” defines which entity you wish to be created. Below this you can then assign values to fields on the new entity. In a more complicated real-world situation you may need to assign quite a few values here. In my example I have done the minimum of just making the new fishing trip linked to the lake I had open. Notice the syntax here. (I actually found different syntax on the Microsoft site which didn’t work!!) As the fishing lake field on the trip is a look-up I need to set the GUID and name for the field.

Agent Script - Add 5

Results

Having completed the steps above, when I view a lake a call script is active giving me an option to create a New Trip.

Agent Script - Add 7

Once selected you can see that a new trip is created below and that tab has become the active tab. It might also be worth noticing that the call script that is now active is “Fishing Trip Tasks”. In my sample application I can that create details of fish caught on that trip etc. You could use this concept to give a new set of answers / tasks once a new case had been created.

Agent Script - Add 7.1

I hope this post has been useful in explaining how to create entities from agent scripts.

13 thoughts on “USD – Agent Script to create an entity

  1. Pingback: Learning USD | My experiences with Microsoft Dynamics CRM

  2. Hi sir,

    I Just read your posts on agent script & instantly the question which came to my mind is that, can we make multiple agent scripts for the agent ? If yes, then what are the specific steps one need to follow ?

    As there might be a scenario where a customer call you regarding let’s say, “Insurance policy query”, so Agent must see a different set of questions on screen using agent script vis-a-vis if a customer’s calls you regarding some other query like “Brokerage”.

    Like

  3. Hi sir,

    I Just read your posts on agent script & instantly the question which came to my mind is that, can we make multiple agent scripts for the agent ? If yes, then what are the specific steps one need to follow ?

    As there might be a scenario where a customer call you regarding let’s say, “Insurance policy query”, so he must see a different set of questions on screen using agent script vis-a-vis if a customer’s calls you regarding some other query like “Brokerage”.

    Like

    • Thanks for reading my blog, I understand your point on changing scripts based on the type of case. I have yet to implement that concept. Although I agree the idea is good, I’d like to see different scripts triggered based on the subject of the case. I believe this should be possible but I will need to have a play to find best approach. I have added it to my growing list of ideas for future posts. Thanks.

      Like

  4. Hi sir, I found this is a useful link on the above discussion :

    http://blogs.msdn.com/b/usd/archive/2015/09/25/the-ins-and-outs-of-unified-service-desk-s-agent-scripting-tool.aspx.

    Here, they had discussed something about the “start task” functionality in agent script inside the USD, currently I am also exploring it, when you get some free time. you can check the above Link, this is from the official Blog which Microsoft running on Unified service desk (USD).

    Thanks !!!!!!!

    Like

  5. Hi sir, I found this is a useful link on the above discussion :

    http://blogs.msdn.com/b/usd/archive/2015/09/25/the-ins-and-outs-of-unified-service-desk-s-agent-scripting-tool.aspx.

    Here, they had discussed something about the “start task” functionality in agent script inside the USD, currently I am also exploring it, when you get some free time. you can check the above Link, this is from the official Blog which Microsoft running on Unified service desk (USD).

    Thanks !!!!!!!

    Like

  6. Hi sir, I have just tried this, & Successfully able to implement it 🙂

    Just follow the below additional step, which I have Mentioned :-

    “Make different Agent script with “start task” enabled as “yes” for all the different Agent script you are going to create for your agent “

    Like

  7. Pingback: USD – Create Opportunity | Microsoft Dynamics CRM and Unified Service Desk

  8. Pingback: USD – Create Opportunity - Microsoft Dynamics CRM Community

  9. Pingback: Learning Unified Service Desk | Microsoft Dynamics CRM and Unified Service Desk

  10. Pingback: USD – Agent Scripts Collection | Microsoft Dynamics CRM and Unified Service Desk

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

  12. Pingback: USD – The Book - Microsoft Dynamics CRM Community

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s