Using below code I am loading share point new list item form in the SP Modal Dialog. Now I want to hide Cancel button of that form.
How can I do that ?
<script type="text/javascript">
var context;
var web;
var user;
var siteUrl = _spPageContextInfo.siteServerRelativeUrl ;
//var loginName = _spPageContextInfo.userLoginName;
//alert(loginName)
var currentLoggedinUser = _spPageContextInfo.userLoginName;
var userTitle;
var flag=true;
var options = { title: "Announcements - New Item",url:"http://sp-qc-01:2525/Lists/testSurvey/NewForm.aspx"};
function init() {
context = SP.ClientContext.get_current();
web = context.get_web();
getCurrentUser();
}
function getCurrentUser() {
user = web.get_currentUser();
context.load(user);
context.executeQueryAsync(onGetUserNameSucces, onGetUserNameFail);
}
function onGetUserNameSucces() {
// TODO: implement your own succes handler
retrieveListItems();
}
function onGetUserNameFail(sender, args) {
// TODO: implement your own fail handler and do some logging
}
function retrieveListItems() {
var oList = context.get_web().get_lists().getByTitle('testSurvey');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'Author\' /><Value Type=\'User\'>'+ user.get_title()+'</Value></Eq></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery);
context.load(collListItem);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
//alert(collListItem.get_count());
if(collListItem.get_count()==0)
{
SP.UI.ModalDialog.showModalDialog(options);
}
//alert(listItemInfo.toString());
}
function onQueryFailed(sender, args) {
alert('Error: ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>