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;");
}

Tuesday, 17 April 2018

Nintex forms set dropdown value

I was working on Nintex forms and I faced a really interesting issue. I need to change default value bind to dropdown control. So easy? Not at all. Here are solution that worked for me:

If you want to set in Nintex forms or List settings -

https://ootbtutorials.com/2016/02/15/setting-field-default-values-in-nintex-forms/

If you want it dynamically changed using jquery-

https://community.nintex.com/thread/16997-how-to-set-default-value-some-option-in-drop-down-list-look-up-using-jquery-or-javascript


Monday, 16 April 2018

SQL Server 2012 64 Bit installation issues

I was installing SQL server 2012 and I have to say it is not at all easy task. I got below issues and solutions:

Issue 1 - Not able to complete installation if you have visual studio 2012 / 2013 installed before.
Solution - make sure you install SQL server 2012 before installation of visual studio 2012 / 2013.
https://stackoverflow.com/questions/14162947/using-ssis-bids-with-visual-studio-2012-2013

If you have installed visual studio, the simplest way is go for SQL server 2014.


Issue 2 - No separate SQL server management studio installation.
Solution - You need to start installation again and run installation again.

Some blog will tell you to go with add feature in installation. but you need to go new installation if you are go with 64 bit.
https://stackoverflow.com/questions/11276167/how-to-install-sql-server-management-studio-2012-ssms-express

Friday, 2 March 2018

How to change date format from "MM/DD/YYYY" (US) to "DD/MM/YYYY" (UK) in SharePoint?

Scenario:
As clients reside in different countries, we need to change date format as per their current use. Recently I was given task to change date format from "MM/DD/YYYY" (US) to "DD/MM/YYYY" (UK).

Note:
Generally my blog contains warning after solution. But as this one affects wide range of settings, I would prefer that you first get approval for this.

Solution:

So the simplest way to achieve this is to change regional settings and SharePoint automatically change the date format accordingly. As I have told in note section, this will change each and every date in system to selected region format. So please get approval first. It may affect other settings too. But I am still not fully got aware where else this can affect.

So follow below steps to change regional settings:


  • Log into your SharePoint Site as the Site Administrator
  • Click Site Actions then Site Settings

  • From the Site Administration section click Regional Settings

  • Select English (United Kingdom) from the Locale: drop down box.

  • Click OK.


Thursday, 1 March 2018

Merge two column values using calculated column in SharePoint

Scenario:

I continuously work in SharePoint and get some experience. Today I got a task to get value of two columns and concatenate it and store it in third column. So I know I can do that using calculated column. I have heard about it. Didn't you? but how exactly it works?

Solution:

So I have google on calculated column and what I found was a hidden treasure. You can get it too by clicking reference link. Microsoft has documented each type of scenario on there. But as my part was only for concatenation of two string, I have used "&" operator in between two columns and it worked great. I have put option related my scenario below:

Column1 Column2 Formula Description (possible result)
Love Thakker =[Column1]&[Column2] Combines the two strings (LoveThakker)
Love Thakker =[Column1]&" "&[Column2] Combines the two strings, separated by a space (Love Thakker)
Love Thakker =[Column2]&", "&[Column1] Combines the two strings, separated by a comma and a space (Love, Thakker)
Love Thakker =CONCATENATE([Column2], ",", [Column1]) Combines the two strings, separated by a comma (Love,Thakker)


Reference:

As I mentioned earlier, you can go on below link and check other scenarios as well:

HTML Print Page functionality

Scenario:

We are getting some simpler task some days and we learn new things about technology or language which is always there, but we are never aware of it. We use it sometimes too but unaware how it is working until you need to develop it.

So we have a simple request that client wants print functionality in page. No big deal. JavaScript provides such functionality with simple command "window.print();". Just use below code and you are good to go:

Code:

<button onclick="window.print();">Print this page</button>


Note:

All browsers use their own way of printing. So the user experience will be different.

Reference:

https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_print

Saturday, 27 January 2018

Anonymous user dispalyed “authentication required” log in pop-up on downloading files

Issue:

We have a simple task recently and that was to enable anonymous access in a site. So easy right? but sometimes it happens if you are not aware how it works, it takes lot of time. Here is same scenario. As we have set up anonymous access, client uploaded some files in library and put it links on a public page. It works fine if you have edit/ full control for site. But if you are anonymous user, you are asked to login.


Solution:

As I said earlier, if you know how it works, you will be able to solve it easily. Only you need to make sure that items are published with major version. If that is done, anonymous user will be able to download files without any issue.

If you search google, you will find that you need to provide "Open item" access to items. If above solution do not solve the issue, below are links to set up open access:





Friday, 15 December 2017

SharePoint 2013: Start Workflow with JavaScript Client Object Model


I have a request to start workflow using client side code. Below is the code that fix my issue:

Code sample:

<button type="button" onclick="Startworkflow(); return false;">Start Workflow</button>

<script src="https://code.jquery.com/jquery-1.7.1.min.js"></script>

<script>

function Startworkflow()

{ LoadScripts(); }

function LoadScripts(){

 SP.SOD.executeFunc("sp.js", "SP.ClientContext" , function(){

  SP.SOD.registerSod('sp.workflowservices.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.workflowservices.js'));

  SP.SOD.executeFunc('sp.workflowservices.js', "SP.WorkflowServices.WorkflowServicesManager", StartWorkflow);

 }) 

}





//Subscription id - Workflow subscription id

//list item id for which to start workflow. If site workflow, then send null for itemId

function StartWorkflow() {

 
   var subscriptionId = "f5fa7d47-52c0-48af-9728-acfad55731d2";

   var itemId = "";



   var ctx = SP.ClientContext.get_current();

   var web = ctx.get_web();

   var wfManager = new SP.WorkflowServices.WorkflowServicesManager(ctx, web);



   var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);

   ctx.load(subscription, 'PropertyDefinitions');

   ctx.executeQueryAsync(

       function (sender, args) {

           var params= new Object();

           //Find initiation data to be passed to workflow.

           var formData = subscription.get_propertyDefinitions()["FormData"];

           if (formData != null && formData != 'undefined' && formData != "") {

               var assocParams = formData.split(";#");

               for (var i = 0; i < assocParams.length; i++) {

                   params[assocParams[i]] = subscription.get_propertyDefinitions()[assocParams[i]];

               }

           }

           if (itemId) {

               wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, params);

           }

           else {

               wfManager.getWorkflowInstanceService().startWorkflow(subscription, params);

           }

           ctx.executeQueryAsync(

               function (sender, args) {

                   console.log("workflow start successfully");

               },

               function (sender, args) {
                 
                   alert('Failed to run workflow');

               }

           );

       },

       function (sender, args) {         

           alert('Failed to run workflow');

       }

   );

 }


As I have a site workflow, I am passing "itemId" parameter value null. You can pass your item id there.


Reference: http://ranaictiu-technicalblog.blogspot.in/2013/06/sharepoint-2013-start-workflow-with.html

Wednesday, 29 November 2017

Hide Social Media share button in Power BI embed code

Recently I was having a task for creating Power BI chart and embedding it in SharePoint. So It is easily available in google. But the tricky part is when you embed it in SharePoint as iframe, it will show share button at bottom of it. Our client do not want that.

Here is the bottom of iframe:








So what is solution:

We add a new div tag and append our iframe within that with little css touch. Below is code for same:

Code sample:

<style>
.iframebox{width:100%; float:left;position:relative; overflow:hidden}
.iframefooter{
    width: calc(100% - 40px);
background: #eaeaea; 
    /*background: #eaeaea;*/
    height: 31px;
    display: block;
    position: absolute;
    bottom: 5px;
    right:40px;
     z-index: 9999999999;
}
.blueborder{
    position: absolute;
    left: 0;
    bottom: 41px;
    height: 1px;
    background: rgb(36, 65, 153);
    z-index: 999999999999999999;
    width: 100%;
}
.ms-dlgContent {z-index: 99999999999 !important;}
</style>


<div class="iframebox">
<!--   Iframe code goes here -->
   <div class="blueborder">&nbsp;</div>
   <div class="iframefooter">
      <br>
      <br>
   <br></div>
</div>

Output:








Happy coding.

SharePoint Server 2016 and 2019 Retirement: What IT Professionals Need to Know

Microsoft SharePoint Server 2016 and 2019 are reaching end of support on July 14, 2026. With the April 2026 feature retirement deadline now ...