问题描述
我试图基于3列来强制使用唯一值。我正在尝试在线使用SharePoint。
- 查阅列
- 选择
- 日历(仅日期)
我尝试使用以下代码,能够从列表中检索现有值,但日历日期选择失败。无法弄清楚该怎么办。有人可以帮忙吗
<script type="text/javascript" src="/sites/Mysite/SiteAssets/jquery.min.js"></script><script type="text/javascript">
//variable to hold Ajax result
var dataResults;
var call = $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Mylist')/Items?" + "$select=Title,Engagement,Period",//Title is a lookup column
type: "GET",dataType: "json",async:false,headers: {
Accept: "application/json;odata=verbose"
},success: function(data) {
dataResults = data.d;
}
});
function PeriodValue(fullDate){
var orderDateString = "2016-10-19T22:00.00Z"; //UTC datetime value from REST response
var orderDate = new Date(orderDateString);
var value= TimeZoneUtilities.utcToLocalTime(_spPageContextInfo.webAbsoluteUrl,orderDate);
alert(value);
var dateValue=null,twoDigitDate=null,twoDigitMonth=null,twoDigitYear,currentDate=null;
dateValue = fullDate.split("T")[0];
twoDigitDate = dateValue.split("-")[2];
twoDigitMonth = dateValue.split("-")[1];
twoDigitYear = dateValue.split("-")[0];
currentDate = twoDigitDate + "/" + twoDigitMonth + "/" + twoDigitYear;
return currentDate;
}
//function to compare user input and existing data
function PreSaveAction(){
var ClientName = document.querySelector('[title="Client Name required Field"]');
var engagement = document.querySelector('[title="Engagement required Field"]');
var period = document.querySelector('[title="Period required Field"]');
ClientName=ClientName.options[ClientName.selectedindex].text;
engagement=engagement.options[engagement.selectedindex].text;
period=period.value;
var c = null;
$.each(dataResults,function(i,item){
c = true;
$.each(item,dt){
console.log(dt.Engagement + ' ' + dt.Period + ' ' +dt.Title);
if (dt.Engagement == engagement && dt.Period == period && dt.Title==ClientName){
c = false;
alert("Already exist");
return c;
}
});
});
return c;
}
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)