Tuesday, 15 May 2018

Hidden Site Collections in SharePoint Online

Recently I was given a task to find site collections that were not visible in admin center but actually users were using them, and the it manager didn't have access on them.

I found two scenarios where this situation is possible. So here is my analysis on them:

  • Scenario I - ContentTypeHub
SharePoint online has a hidden site collection named "contenttypehub" (URL - /teams/contentTypeHub). You can host your content types here. They will be available in all the site collections. 
  • Scenario II- SharePoint Group Sites
If you have created Office365 groups, you will have a separate site collection of each group created where group members can share & collaborate. 

Thursday, 3 May 2018

Nintex Form "RegisterAfterReady" load event

Few more tips on Nintex forms. If you have an action that you want to occur before nintex load page, what are the options? If you have asked me yesterday, I would have easily say document ready event. But today I have few more option. 

Here are the options:

  • NWF.FormFiller.Events.RegisterBeforeReady
  • NWF.FormFiller.Events.RegisterAfterReady
  • NWF$(document).ready
Well we all know 3rd option. Let me give some tips on 2nd option. We have a requirement that whenever we open any item, we need to show user what to do in the form. As the form was submitted at different level by approval process, we need to show different guide for different user. 

Document ready event was firing so quickly that we were not able to get all the information we need from form. So we used RegisterAfterReady event. so once the form is ready with our data filled in that, we can open a dialog showing our own page.

below is solution that we used:

Solution:

ShowInitialPop() {
    var widthValue = 600;    
    var options = {
        title: "",
        width: widthValue,
        height: 520,
        url: sr_siteUrl + "/SitePages/StartPopUp.aspx?IsDlg=1"
    };

    SP.UI.ModalDialog.showModalDialog(options);
    NWF$("#dialogTitleSpan").hide();
    NWF$("#dlgTitleBtns").hide();
}

NWF.FormFiller.Events.RegisterAfterReady(function () {
// your code
    ShowInitialPop();
    
});
Reference:

https://help.nintex.com/en-us/sdks/sdk2013/FormSDK/Topics/SDK_NF_CON_NF_Events.htm

Update item in Nintex form using SPService code

I am working on few forms developed in Nintex and need to do some CRUD operations. Here is sample code for update item.

Prerequisite:

You need to provide reference of jquery.SPServices-2014.01.NF.min.js file in your script file.

Solution:

function oData_SaveExitPendingHRO() {

//This line is used to get drop down value
    var closedStatusID = oData_GetIDFromDdl(NWF$('#' + jsCtrl_ddlClosedStatus).val());
    var closedStatus = oData_GetTextFromDdl(NWF$('#' + jsCtrl_ddlClosedStatus).val());

//This one is used to get textbox
    var actionComments = '';
if (typeof(jsCtrl_txtActionComments) != "undefined" && closedStatus !=""){
actionComments = NWF$('#' + jsCtrl_txtActionComments).val();
}

//This one is used to get date field. Then we convert it our required format
    var effectiveDate1 = NWF$('#' + jsCtrl_dtpEffectiveDate).val();
if (typeof(effectiveDate1) != "undefined" && effectiveDate1 != "empty") {effectiveDate1 = oData_ConvertToISOString(effectiveDate1);}

//This one is used to get people picker field.
var varHROSpecialist = NWF$('#' + jsCtrl_pickerHROSpecialist).val();

//This one is used to get id.
    var itemID = NWF$('#' + jsCtrl_txtID).val();

    var currentUserAccountName = NWF$('#' + jsCtrl_txtCurrentUserAccount).val();

// Special call to convert special character in html code
actionComments = encodeXMLSpecialChars(actionComments);

    if (!oData_IsNullOrEmpty(itemID)) {

        //Update Action Closure Section
        NWF$().SPServices({
            operation: 'UpdateListItems',
            async: false,
            listName: 'ListName',
            updates: '<Batch OnError="Continue">' +
            '<Method ID="1" Cmd="Update">' +
            '<Field Name="ID">' + itemID + '</Field>' +
            '<Field Name="ClosedStatus">' + closedStatus + '</Field>' +
            '<Field Name="ClosedStatusID">' + closedStatusID + '</Field>' +
'<Field Name="ActionComments">' + actionComments + '</Field>' +
'<Field Name="EffectiveDate">' + effectiveDate1 + '</Field>' +
'<Field Name="HROSpecialist">' + oData_ParsePeoplePickerValue(varHROSpecialist) + '</Field>' +
            '</Method>' +
            '</Batch>',
            completefunc: function (xData, Status) {
                var lowerStatus = Status.toLowerCase();
                if (lowerStatus != null && typeof (lowerStatus) != "undefined" && lowerStatus != "" && lowerStatus == "success") {                 
alert('Command success');

                    //Redirect after saving
        document.location.href = oData_siteUrl,true;
                }
                else {
                   alert('Command failure');
                }
            }
        });
       
    } else {
        alert('Error. Please contact the Administrator.');
    }
}

function oData_ConvertToISOString(eDateValue) {
    var isoDate = new Date(eDateValue);
    if (eDateValue != null && typeof (eDateValue) != "undefined" && eDateValue != "") {
        var day = isoDate.getDate();
        var mm = isoDate.getMonth() + 1;
        var yyyy = isoDate.getFullYear();
        isoDate = yyyy.toString() + "-" + ("0" + mm).slice(-2) + "-" + ("0" + day).slice(-2) + "T09:00:00Z";
    }

    return isoDate;
}

function oData_ParsePeoplePickerValue(eValue) {
    var pplValue = "";
    if (!oData_IsNullOrEmpty(eValue)) {
        pplValue = eValue.replace(";", "").replace("i:0#.w|", "-1;#");
    } else {
        pplValue = "";
    }

    return pplValue;
}


function encodeXMLSpecialChars(unsafe) {
    if (unsafe == null || typeof (unsafe) == "undefined" || unsafe == "") {
        unsafe = "";
    }

    return unsafe
        .replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;");
}