Friday, March 9, 2018

Get seconds from Datetime field in Nintex workflow

I was trying to generate a document from Nintex workflow and name the document with values from current item including formatted Created datetime field.

When I try to use fn-FormatDate function, Nintex return 00 for "seconds" part of the time. Followed below approach to get the required format in 2 actions.

Action 1: Take Calculate Date action from Operations tab and configure as below. The action will store ISO format of Modified datetime in workflow variable varISODateTime


Action 2: Take Set Variable action from Operations tab and configure as below.

Title - fn-FormatDate(Modified, "MMMM dd HHmm")fn-Substring(varISODateTime,17,2).docx

The above formula is to generate document title as per my requirement. You may modify the format as per your requirement. fn-Substring(varISODateTime, 17, 2) is the part that extracts seconds part of the time.


Hope this helps you!

Wednesday, February 28, 2018

Nintex - REST API call User Profile Service with special chars in accountname

When you got special characters in REST API URI for GET, they cause error.

Use encodeURIComponent to encode the special characters


var userProfUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='"+encodeURIComponent("i:0e.t|pingfedratests|userId@company.com")+"'"
NWF$.ajax({
url: userProfUrl,
type: "GET",
headers: { "accept": "application/json;odata=verbose" },
success: function (data) {

//var userDisplayName = data.d.DisplayName;
var properties = data.d.UserProfileProperties.results;
var firstName;
var lastName;
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
if (property.Key == "FirstName") {
firstName = property.Value;
}
if (property.Key == "LastName") {
lastName = property.Value;
}
}
NWF$('#' + txtUserFullName).val(firstName + ' ' + lastName);

},
error: function () {
alert("Error getting User Full Name!");
}
});