我想创建一个脚本,该脚本将由Share中的操作/文件夹规则验证。
我正在考虑使用先前声明的变量,如下所示:
var clientsite = "client"
var docfolder = "document_alias"
var docyear = 2015
我的代码就像这样:
var folder = search.luceneSearch(" PATH:\"/app:company_home/st:sites/**clientsite**/**docfolder** \" AND TYPE:\"cm:folder\" AND \@cm\\:name:\"**docyear**\" ");
if (folder == null || folder.length == 0) {
//create new folder called 'docyear'
}
else {
//move to the already existing folder related to 'docyear'
}
粗体(我试图用代码中的*加粗项目,抱歉)值将是之前声明的变量。
有没有办法像这样使用变量?
谢谢!
答案 0 :(得分:0)
当然!你只需要附加它们,标准的javascript字符串创建不支持模板参数,所以走你的路线
var folder = search.luceneSearch(" PATH:\"/app:company_home/st:sites/**clientsite**/**docfolder** \" AND TYPE:\"cm:folder\" AND \@cm\\:name:\"**docyear**\" ");
并使其像
var folder = search.luceneSearch(" PATH:\"/app:company_home/st:sites/"+clientsite+"/"+docfolder+" \" AND TYPE:\"cm:folder\" AND \@cm\\:name:\""+docyear+"\" ");