Pages

Friday, February 1, 2019

Sharepoint JSOM client object model code to retrieve other list item in Nintex Form

When using the SharePoint JavaScript client object model, your code needs to be broken up into two parts: the first part specifies what you want to get, and involves you loading queries and commands into an SPClientContext object; the second part lets you manipulate the results of the query to SharePoint, and runs as an asynchronous callback of the query execution.
  1. Create your context, specify which lists you want to access, etc.
  2. Run clientContext.executeQueryAsync() (where clientContext is an SP.ClientContextobject), and pass in delegate functions to run on success or failure
  3. In your "onSuccess" delegate function, you can work with the results of the commands you loaded up in step 1



function FormLoading()
{
console.log('Inside Jcode Form Loading Calls');
NWF$("#" + JSLeaveType).change(function()
{

EmpLeaveBalance();
});
}

function  EmployeeLeaveBalance()
{
try
{
NWF$("#" + JSLeaveBalance).val("");
var clientContext = SP.ClientContext.get_current(); 
var web = clientContext.get_web(); 

var oList = clientContext.get_web().get_lists().getByTitle("LeaveSBalanceS");

var newCRUsername = varCRUsername.replace('downlevelTextBox','upLevelDiv');
var varCRUsernamevalue= NWF$('#' + newCRUsername).find('span.ms-entity-resolved').attr('title');
var lists = new SPAPI_Lists('');
var userprofiles= new SPAPI_UserProfile('');
var currentUserProfile = getUserProfileInfo(userprofiles,varCRUsernamevalue); 
var userFullName = getFullName(currentUserProfile);
//alert('UserFullName  '+userFullName);
//var varCurrentUser = clientContext.get_web().currentUser();
//var accountname = currentUser.get_title();
//console.log("accountname --> " + accountname);
var camlQuery = new SP.CamlQuery();
/* Use a CAML query to filter your results */
camlQuery.set_viewXml( +userFullName+ );

//camlQuery.set_viewXml('' + userFullName + '' + (new Date()).getFullYear() + '');
/* get the list item collection from the list */
        var oListItems = oList.getItems(camlQuery);
/* tell SharePoint to load the list items */
clientContext.load(oListItems);
  
//var LeaveType=NWF$("#" + JSLeaveType).val();   
var LeaveType=NWF$("#" + JSLeaveType + ' option:selected').text(); //Nintex form control is lookup field then get selected text
//clientContext.load(ListItem,'Include(AnnualLeave)','Include(MedicalLeave)'); 
/* execute the query to get the loaded items */

    clientContext.executeQueryAsync(
        /* onSuccess Function */
        Function.createDelegate(this, function () {
            /* 
            now that the query has run, you can get an enumerator 
            from your list item collection 
            */
            var arrayListEnum = oListItems.getEnumerator();
            var ids = [];
            while (arrayListEnum.moveNext()) {
console.log("New Inside While array loop");
//console.log(arrayListItem.get_current());
var listItem = arrayListEnum.get_current();
console.log(listItem.get_item('Title'));
console.log(listItem.get_item('AnnualLeave'));
console.log(listItem.get_item('MedicalLeave'));
//var varLeaveTypeName = NWF.RuntimeFunctions.parseLookup(NWF$('#'+JSLeaveType).val(),true); // Not working
var varLeaveTypeName =NWF$('#'+ JSLeaveType + ' option:selected').text();
console.log("varLeaveTypeName with Space  "+varLeaveTypeName);
varLeaveTypeName=varLeaveTypeName.replace(/\s+/g, ''); //Remove Space Javascript varaible
console.log("varLeaveTypeName without space "+varLeaveTypeName);
var varLeaveBalance = listItem.get_item(varLeaveTypeName);
console.log(varLeaveBalance);
            }
//console.log("Outside While array loop");
            
        }),
        /*onFailure Function*/
        Function.createDelegate(this, function (sender, args) {
            alert("Whoops: " + args.get_message() + " " + args.get_stackTrace());
        })
);
 }
catch(e)
{
alert("EmployeeLeaveBalance ERROR is " + e);
}
 }


Tuesday, January 15, 2019

Recovering the suspected SharePoint 2013 Config database

Issue:

Central Administrator site not accessible.



Open SQL Server -- New Query, run these command to repair the SharePoint config database.




— Use the Master database 
Use Master

— Verify that database has issues 
EXEC sp_resetstatus 'SharePoint_Config'

— Put the database in emergency mode 
ALTER DATABASE SharePoint_Config SET EMERGENCY 
DBCC checkdb('SharePoint_Config')

— Set the database in single user mode 
ALTER DATABASE SharePoint_Config SET SINGLE_USER WITH ROLLBACK IMMEDIATE

— Repair the database with data loss 
DBCC CheckDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS)

— Set the database in multi-user mode 
ALTER DATABASE SharePoint_Config SET MULTI_USER

— Verify that database is reset 
EXEC sp_resetstatus 'SharePoint_Config'

Friday, January 11, 2019

Sharepoint Online - Quick Edit supports JS Link and Client Side Rendering

The sharepoint online list quick edit (Data Sheet View) would support Client Side Rendering Code (CSR).

when I renamed a file to become “kar.txt” it turns the background green &  text white colour tag.   This could be leveraged to give end users real-time feedback on the values entered.   Unlike a JQuery page load event which only triggers once, this triggers per row as values are changed.

 Upload JS file to Site Asset library and Provide in the following

~site/SiteAssets/CSSQEdit.js




Thursday, December 6, 2018

Hide Nintex form fields via Custom CSS


Add this name "nf-hide-calculatedcolumn" in the CSS class from calculated field.


Add in this CSS code from Custom CSS Section.

.nf-hide-calculatedcolumn 
{
visibility:hidden;
}


All of your CSS related control will be hidden.


Monday, October 15, 2018

Microsoft Flow to Update Azure AD User's Mobile Number via Custom Graph API App


Issue: When Updating Azure AD User Mobile number via Microsoft flow then we are getting error is Graph API - Insufficient privileges to complete the operation.

Our Techie team breaking head for few days and resolved issue and found solution.

Solution: Create Custom App for Graph API then Create HTTP Web service call inside flow to access Custom Graph API to update Azure AD User Mobile Number.