Get CSV info, script example?

Discussion in 'Call Flow Designer' started by VictorSP, Mar 22, 2018.

Thread Status:
Not open for further replies.
  1. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    65
    Likes Received:
    12
    Hello,

    Could anyone provide an example of script to get info from CSV, please? We want to check into the CSV the PIN and get the destination asociated. CSV example:

    PIN, Destination
    111,8899
    222,8888
    333,8877
    ...

    Thanks!
    Victor
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,355
    Likes Received:
    108
    Hello @VictorSP,

    Please take a look at the following article:
    https://www.3cx.com/docs/cfd-creating-phone-support-portal-3/

    The script there validates ID and PIN. You need to validate the PIN and return the Destination, so you can easily change the script as follows:
    Code:
    public string GetDestinationForPin(string fileContent, string pin)
    {
      foreach (string line in fileContent.Split('\n'))
      {
        string[] lineParts = line.Trim().Split(',');
        if (lineParts.Length == 2)
        {
          string customerPIN = lineParts[0];
    
          if (pin == customerPIN)
            return lineParts[1];
        }
      }
      return "";
    }
    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    VictorSP likes this.
  3. VictorSP

    Joined:
    Sep 6, 2016
    Messages:
    65
    Likes Received:
    12
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.