CrossSite Lookup - value from URL parameter

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

24 Aug 2016

Hello!

I faced to very strange issue, that appears in IE only (IE 11 in my case). The case is - I need to feel the CSL field with default value, that I receive from URL parameter. To reproduce error:

1. Define the parameter from URL, check wheither it is not a NaN

2. Ask SP Resrt web service to receive the title of item, that should be in CLS field

3. After the promise resolved, fill the CSL field with such string: parameter + ";#" + TitleValueReceivedFromAjax



Everything works well in Chrome, but when I open the link http://NewItemForm.aspx?tra-ta-ta&Parameter=122 in IE, I see the exception Syntax error, unrecognized expression: MyParameter;#Title, generated in plumsail.csl.jquery.js, str: 2, col: 12725. When I press F5 (even ctrl+F5) - everythig OK, value appears in field.



CallStack is:

ga.error [Строка: 2, столбец: 12725], plumsail.csl.jquery.js

ga.tokenize [Строка: 2, столбец: 18635], plumsail.csl.jquery.js

ga.select [Строка: 2, столбец: 21380], plumsail.csl.jquery.js

ga [Строка: 2, столбец: 7357], plumsail.csl.jquery.js

find [Строка: 2, столбец: 23658], plumsail.csl.jquery.js

m.fn.init [Строка: 2, столбец: 24205], plumsail.csl.jquery.js

m [Строка: 2, столбец: 386], plumsail.csl.jquery.js

setVal [Строка: 23, столбец: 28310], plumsail.csl.select2.js

val [Строка: 23, столбец: 28910], plumsail.csl.select2.js

Anonymous function [Строка: 23, столбец: 31122], plumsail.csl.select2.js

each [Строка: 2, столбец: 2968], plumsail.csl.jquery.js

m.prototype.each [Строка: 2, столбец: 826], plumsail.csl.jquery.js

a.fn.select2 [Строка: 23, столбец: 30611], plumsail.csl.select2.js

value [Строка: 2, столбец: 24551], plumsail.fd.core.js

h.prototype.value [Строка: 2, столбец: 29878], plumsail.fd.core.js

o.prototype.value [Строка: 2, столбец: 10568], plumsail.fd.core.js

_fillBizTripFields [Строка: 951, столбец: 13], fd_%D0%AD%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82_New.aspx



The script I use bellow:





//namespace

var BizTripReport = BizTripReport || {};



//class BisTripData

BizTripReport.BisTripData = function (requestId) {

var _bizTrip = {};

_bizTrip.Delegate = {};



//Если форма иициализировалась с RequestId из URL, то используем его для заполнения полей

if (requestId){

//Заполняем поле "Заявка"

_getBizTripInfo(requestId)

.then(_fillBizTripFields);

}



function _getBizTripInfo(requestId){

var dfd = $.Deferred();

var baseUrl = SP.Utilities.UrlBuilder.urlCombine(

_spPageContextInfo.webServerRelativeUrl,"/_api/Web/Lists"

);



baseUrl += "(guid'19278e03-4ec0-4379-b77c-74cb8a22d703')/items("+requestId+")?$expand=BizTripDelegate&$select=OrderNr,OrderDate,StartDate,Country,City,BizTripPurpose,BizTripDelegate/Title,BizTripDelegate/Name,OData%5F%5FEndDate,Title";



$.ajax({

url:baseUrl,

type: "GET",

contentType: "application/json;odata=verbose",

headers: {

"accept" : "application/json;odata=verbose"

},

success: onSuccess,

error: onError

});



function onSuccess(data){

if (data){

_bizTrip.Title = data.d.Title;

var delegateNameRaw = data.d.BizTripDelegate.Name;

_bizTrip.Delegate.Login = delegateNameRaw.substr(delegateNameRaw.indexOf("\\")+1);

_bizTrip.Delegate.Name = data.d.BizTripDelegate.Title;

_bizTrip.Purpose = data.d.BizTripPurpose;

_bizTrip.Destination = data.d.Country + " " + data.d.City;

_bizTrip.StartDate = data.d.StartDate;

_bizTrip.EndDate = data.d.OData__EndDate;

if ( data.d.OrderNr && data.d.OrderDate)

_bizTrip.Order = data.d.OrderNr + " от " + moment(data.d.OrderDate).format("DD.MM.YYYY");

}

dfd.resolve();

}



function onError(data, errorCode, errorMessage){

console.log(errorMessage);

dfd.reject('Failed to load due to : '+errorMessage);

}



return dfd;

}



function _fillBizTripFields(){

fd.field("BizTripOrder").value(_bizTrip.Order);

fd.field("BizTripStartDate").value(moment(_bizTrip.StartDate).format("DD.MM.YYYY"));

fd.field("BizTripEndDate").value(moment(_bizTrip.EndDate).format("DD.MM.YYYY"));

fd.field("BizTripDestination").value(_bizTrip.Destination);

fd.field("BizTripPurpose").value(_bizTrip.Purpose);



//Заполняем поле с сотрудником

fd.field("ResponciblePerson").control('ready',function(picker){

picker.AddUserKeys(_bizTrip.Delegate.Login);

});



if (!fd.field("BizTrip").value().length){

fd.field("BizTrip").value(requestId + ";#" + _bizTrip.Title );

}

}



function _resetBizTripFields(){

fd.field("BizTripOrder").value("");

fd.field("BizTripStartDate").value("");

fd.field("BizTripEndDate").value("");

fd.field("BizTripDestination").value("");

fd.field("BizTripPurpose").value("");



//Заполняем поле с сотрудником

fd.field("ResponciblePerson").value("");

fd.field("Department").value("");

fd.field("Position").value("");

}



var publicMembers = {

BizTrip : _bizTrip,

FillBizTripFields : function(requestId) {

_resetBizTripFields();

if (requestId) {

_getBizTripInfo(requestId)

.then(_fillBizTripFields);

}

}

};

return publicMembers;

};





//-----------------------------------------------------------------------------------------------------------------------------------------//

//var requestIdFromUrl =

var requestId = parseInt(GetUrlKeyValue("RequestId", true, window.location.href, false));



SP.SOD.executeFunc("sp.js", 'SP.Utilites',

function () {

BizTripReport.trip = new BizTripReport.BisTripData(requestId);



//Подписка на события - изменилась заявка

fd.field("BizTrip").change(function () {

//Получаем первую заявку в поле

var requestsString = fd.field("BizTrip").value().toString();

var requests = requestsString.split(",");

var firstRequestId = parseInt(requests[0]);



if (firstRequestId !== requestId){

requestId = firstRequestId;

BizTripReport.trip.FillBizTripFields(requestId);



}

});

});

User avatar
Alexey Babin
Posts: 23
Joined: Wed May 11, 2016
Contact:

24 Aug 2016

The problem is solved - instead of fd.field("CSLField").value(parameter + ";#" + titleTitle ) should use

fd.field("CSLField").value([parameter, titleTitle]).

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests