Dear All,
I've Infopath multiline text box column in Document Library so I want to take the row count from multiline text box and this row count number need to add in Task List. So from Task list based on the number I need to create the workflow alert mail.
(function () {// Create object that have the context information about the field that we want to change it's output render
var bodyFiledContext = {};
bodyFiledContext.Templates = {};
bodyFiledContext.Templates.Fields = {
// Apply the new rendering for Body field on list view
"SCCount": { "View": bodyFiledTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(bodyFiledContext);
})();
function bodyFiledTemplate(ctx) {
if(ctx.CurrentItem.Server_x0020_Name1 != ""){
var lines = ctx.CurrentItem.Server_x0020_Name1.split("<br>");
return lines.length; }
}
First Part above code, Talking the row count from multiline text box and showing in column "SCCount"is working fine but when I try to insert it this count it is not working for me. Below is JavaScript code-- Please advice.
var bodyFiledContext = {};(function () {
bodyFiledContext.Templates = {};
bodyFiledContext.Templates.Fields = {
"SCCount": { "View": bodyFiledTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(bodyFiledContext);
})();
var nom;
var ItemId;
function bodyFiledTemplate(ctx) {
if(ctx.CurrentItem.Server_x0020_Name1 != ""){
var lines = ctx.CurrentItem.Server_x0020_Name1.split("<br>");
nom=lines.length;
ItemId = ctx.CurrentItem.ID;
ExecuteOrDelayUntilScriptLoaded(copy, "sp.js");
}
}
var clientContext;
var oListItem;
var File;
function copy() {
debugger;
clientContext = new SP.ClientContext("http://SP/IT");
var oList = clientContext.get_web().get_lists().getByTitle('Shared Documents');//change the List name to the list that you want to copy item to
oListItem = oList.getItemById(ItemId);
File = oListItem.get_file();
clientContext.load(File);
clientContext.executeQueryAsync(onQuerymSucceeded,onQueryFailed);
}
function onQuerySucceeded() {
alert('Item created');
}
function onQuerymSucceeded() {//if(File.get_checkOutType() == SP.CheckOutType.online)
// File.checkOut();
oListItem.set_item('SCCount', nom);
oListItem.update();
clientContext.load(oListItem);
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}