cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
17309
Views
9
Helpful
60
Replies

Setting a Call Variable using JavaScript

Gerry O'Rourke
Spotlight
Spotlight

Hi,

I can see how to retrieve the ICM call variables using Finesse JavaScript Library e.g.

dialog.getMediaProperties();

But is it possible to set/update the call variables using the Finesse JavaScript Library?

If so, does anyone have a simple example?

Gerry.

60 Replies 60

Understanding the Underlying REST API used to do this (showing this is possible)
https://developer.cisco.com/docs/finesse/#!dialogupdate-call-variable-data/dialogupdate-call-variable-data

 

JavaScript Library
https://developer.cisco.com/docs/finesse/#!javascript-library

 

finesse.restservices.Dialog.Actions

UPDATE_CALL_DATA - Updates data on a Call Dialo

 

Example
https://community.cisco.com/t5/collaboration-documents/update-call-data-using-finesse-gadget/ta-p/3613162

 

Regards,

Gerry

 

Hi Gerry,

 

Can you please provide a sample code. as far as i understand is we can pass only one variable and its value as per below code.

finesse.restservices.Dialog.prototype.updateCallVariable = function (name, value, options)
{
this.isLoaded();

var callvar = {
"name" : name,
"value" : value

};
var callvariable = { "CallVariable" : callvar };




var mediaProperties =
{
"callvariables": callvariable

};

options = options || {};
options.content = {};
options.content[this.getRestType()] =
{
"mediaProperties": mediaProperties,
// "requestedAction": finesse.restservices.Dialog.Actions.UPDATE_CALL_DATA
"requestedAction": "UPDATE_CALL_DATA"
};
options.method = "PUT";
this.restRequest(this.getRestUrl(), options);

return this;
};

Hi,

 

As Gerry pointed out, you need to understand the REST API to make the modifications to the gadget code. Per the REST API documentation you can put the following:

 

<Dialog>
   <requestedAction>UPDATE_CALL_DATA</requestedAction>
   <mediaProperties>
      <callvariables>
         <CallVariable>
            <name>callVariable1</name>
            <value>123456789</value>
         </CallVariable>
         <CallVariable>
         ... Other call variables to be modified ...
         </CallVariable>
      </callvariables>
   </mediaProperties>
</Dialog>

 

 

As you can see from the above, you just need to put multiple <CallVariable> tags within the <callVariables>.

 

In the code you pasted, you have:

 

var mediaProperties =
{
"callvariables": callvariable
};

 

 

So what you need to do is something like this:

 

var callvar2 = {
"name" : name,
"value" : value

};
var callvariable2 = { "CallVariable" : callvar2 };

var mediaProperties =
{
"callvariables": {
      callvariable,
      callvariable2
};

 

 

I am just writing the above from memory, so my syntax might not be completely right, but hopefully you get the point.

 

Thanx,

Denise

Hi Denise,

I am able to update now. Thanks for reply.

 

Can we add response event handler to this code if yes can you please suggest?  

finesse.restservices.Dialog.prototype.updateCallVariable = function (name, value, options)
{
this.isLoaded();
var callvar = {
"name" : name,
"value" : value
};
var callvariable = { "CallVariable" : callvar };
var mediaProperties =
{
"callvariables": callvariable
};

options = options || {};
options.content = {};
options.content[this.getRestType()] =
{
"mediaProperties": mediaProperties,
// "requestedAction": finesse.restservices.Dialog.Actions.UPDATE_CALL_DATA
"requestedAction": "UPDATE_CALL_DATA"
};
options.method = "PUT";
this.restRequest(this.getRestUrl(), options);

return this;
};

 

Hi,

 

Yes, in your options, you can have options.success and options.error which both would take a handler.

 

Thanx,

Denise

HI dlender,

I have an ECC variable name user.MembID and I am trying to set its value using the script you have posted. I am not getting any error and I am not getting variable updated value in call grid. however it is working for regular call variable updation. please suggest where i am missing any things?

Thanks

Navin Saxen

Try this one.

What??? havent seen any link or attachement

-- Navin

I don't know why you can't see it but I attached it to that post.

I can see two attachments and both of them were 2 year old. i cant find any recent attachment and I am using the same script

finesse.restservices.Dialog.prototype.updateCallVariable =  function (name, value, options)

    {

        this.isLoaded();

                                var callvar = {

                                                  "name" : name,

                                                  "value" : value

                                };

                                var callvariable = { "CallVariable" : callvar };

        var mediaProperties =

        {

            "callvariables":  callvariable

        };

        options = options || {};

        options.content = {};

        options.content[this.getRestType()] =

        {

            "mediaProperties": mediaProperties,

          // "requestedAction": finesse.restservices.Dialog.Actions.UPDATE_CALL_DATA

                                  "requestedAction": "UPDATE_CALL_DATA"

        };

        options.method = "PUT";

        this.restRequest(this.getRestUrl(), options);

        return this;

    };

HI Alexis,


Thanks for the attachment. Just checked the code and find that this is the same code i am using.

it is just working fine for CallVariable1 etc.. but it is not updating the ECC like user.MembID in my case.


-Navin

Hi Navin,

What do you see in the client & webservices logs when you make the call variable update request? What is the error you get?

Also, are you sure you have the right call variable name? You should look at the dialog notification you get when the call arrives.

Thanx,

Denise

eliptsin
Cisco Employee
Cisco Employee

David

My customer is going to upgrade to UCCE V10 and replace CTIOS with Finesse.

The showstopper is ability to write to Var fields.

Could please help me with

1     How to apply provided SetCallVariable gadget to Finesse

2     Do you know if/when Set Variable gadget will be available for inbound calls

Thanks

The ability to write to callvariables exists now in Finesse 10.0, it just requires a custom gadget. I am not sure I understand what is a showstopper, unless it is the ability to write callvars using the out of box CallControl gadget that comes with Finesse.

I am also not sure what help you are needing.  Have you tried to use the SetCallVariable sample gadget attached to this thread?

If you are unfamiliar with custom gadgets, see the Getting Started page

The SetCallVariable sample shows how to set callvariables on the currently active call, so it handles inbound calls.