export CFD has Error

Discussion in 'Call Flow Designer' started by Mekaeil Andisheh, Apr 10, 2018.

Thread Status:
Not open for further replies.
  1. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    Hi
    @edossantos
    @YiannisH_3CX

    it is my CFD :
    we have a webservice and get result value , after that assign the result value to the variable and finally transfer to call with result value webservice,
    the result value Webservice = Extension Sales team


    [​IMG]

    when i want to build it and upload in account , these errors happened :

    [​IMG]
     

    Attached Files:

    #1 Mekaeil Andisheh, Apr 10, 2018
    Last edited: Apr 11, 2018
    maziyarvex likes this.
  2. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    more details :

    webservice :
    [​IMG]

    assign to variable :
    [​IMG]

    transfer call :
    [​IMG]
     

    Attached Files:

  3. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    I resolved my Errors :)
    all of the Error happened because of Double quotation in Webservice address.
    "Webservice Address"
     
  4. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,351
    Likes Received:
    108
    Yes, the address is an expression. If you need to enter a constant string value, use the "Constant string" option from the Expression Editor, which will add the quotes and escape any character you need.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Mekaeil Andisheh likes this.
  5. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    Thank you @edossantos ,

    we got the value with web service like this : {"result":134}

    and i want to set only the value(134) into variable in CFD.

    how i can assign 134 to variable with Assign to variable component in CFD ?

    [​IMG]

    thanks
     

    Attached Files:

  6. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    According to this Article ,

    our json data :

    Code:
    {
    "result": 134
    }


    my component :

    lse.png

    my C# Code :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;
    using Newtonsoft.Json;
    
    namespace Parser
    {
    
        public class MyParser
        {
    
            public string JsonParser(MyJson model)
            {
                return model.result;
           
            }
       
        }
       
    
        public class MyJson
        {
            public int result { get; set; }
        }
    
    }
    but it does not work and we don't have any return value.

    and after that i want to assign the returned value and transfer to call. but we don't have any return value.
     
  7. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,351
    Likes Received:
    108
    You have different options here. If you always get such a simple JSON maybe you can just create a simple algorithm to parse the string by searching substrings...

    If you want to use the Newtonsoft library, that's OK, but you need to consider the different cases. Maybe you need other script first to check if you have that JSON or not...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    @edossantos

    thanks for your answer.

    i have some question, please answer me , thanks.

    i have a some Code like this :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;
    using Newtonsoft.Json;
    
    namespace CallerExtension
    {
    
        public class ExtValue
        {
    
            public string returnExt(string json)
            {
       
                string str          = json.ToString();  //  {"result":134}
                string searchString = '{"result":';    
                int startIndex      = str.IndexOf(searchString); // 10
               
                return str.Substring(startIndex, str.Length - 1);  //
               
            }
       
        }
       
        public class MyJson
        {
            public int result { get; set; }
        }  
    
    
    }
    and i can't understand what is the Object type and how i fill it and Method name.
    before use the "Launch External Script" component i tested the response JSON and it is correctly worked but the "Launch External Script" doesn't work!

    can you tell me how i can write the code in Script component , and how i can fill this component and how i can send json data to this script in component ?

    i couldn't find any document about External Script Component in CFD.
     
  9. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,351
    Likes Received:
    108
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Mekaeil Andisheh likes this.
  10. Mekaeil Andisheh

    Joined:
    Apr 8, 2018
    Messages:
    15
    Likes Received:
    2
    Thank you so much @edossantos. :)

    i solved the problem.
    this is final code, i like to share my code maybe it is useful for someone :

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;
    using Newtonsoft.Json;
    using System.Collections.Generic;
    
    namespace CallerExtension
    {
        
        public class MyJson
        {
            public int result { get; set; }
            
            public int returnExt(string json)
            {
                var getJson = JsonConvert.DeserializeObject<MyJson>(json);
                return getJson.result;
            }   
            
        }   
    
    }
    and this is the component :

    finalcomponent.png
     
Thread Status:
Not open for further replies.