简体   繁体   English

Google Scripts / Sheets 添加前缀国际电话

[英]Google Scripts / Sheets Add prefix international phone

thanks for your invaluable help.感谢您的宝贵帮助。

I have a google form to which I would like to activate a script that automatically changes the telephone number entered by the customer.我有一个谷歌表单,我想激活一个脚本来自动更改客户输入的电话号码。

Example (column G): eg [User Input] = [Final Cell Value]示例(G 列):例如 [用户输入] = [最终单元格值]

3331231646 = +393331231646
3251022878 = +393251022878

I'm trying to solve this problem, can anyone help me?我正在尝试解决这个问题,有人可以帮助我吗?

thanks a lot多谢

Before proceeding to creating the script, add installable trigger first.在继续创建脚本之前,首先添加可安装触发器。 See below steps on how to add triggers:请参阅以下有关如何添加触发器的步骤:

1.) In your Script Editor, go to Edit tab and click Current project's triggers 1.)在您的脚本编辑器中,go 到编辑选项卡并单击当前项目的触发器在此处输入图像描述

2.) Click Add Trigger in the lower right corner 2.) 点击右下角的添加触发器

在此处输入图像描述

3.) In the Select event type drop down, select On form submit 3.) 在Select 事件类型下拉列表中,select在表单上提交在此处输入图像描述

4.) If there's an authentication appears, just select your account and click Allow 4.)如果出现身份验证,只需 select 您的帐户,然后单击允许

5.) You will see these details after clicking Save 5.) 单击保存后,您将看到这些详细信息在此处输入图像描述

This is my sample script that can achieve this target:这是我可以实现此目标的示例脚本:

function onEdit(e) {
    var range = e.range;
    var responseArray = e.values;
    var countryCode = "+39";

    //For this part, you just need to change the index[] to the specific column of mobile number in your spreadsheet, count starting from 0, equivalent to column A. 
    //In my sample, the column of mobile number on my spreadsheet is at column G, so the index I indicated was 6.
    responseArray[6] = countryCode + e.values[6]; 
    //A Range object is representing the cell or range of cells that were last added/inputted in the spreadsheet from the form.
    range.setValues([responseArray]);
}

See sample output below:请参阅下面的示例 output:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM