Page 1 of 1

JSON

Posted: 21 Oct 2015
by Sebastian Haugland
Hi

I have made a HTML with the contens below (the button is not in use yet)

It works fine as it is below but I want to make it dynamical ie change

THIS: obj = {"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567","MC":"Yes"};

to THIS var obj=fd.field('JSON').value();
ie read into obj from a sharepoint list multiline field, but it does not work - any suggestions?


MY HTML:

<!DOCTYPE html>

<html>

<body>



<h2>JSON Object Creation in JavaScript</h2>

<button onclick="hh()">JSON</button>



<p id="demo3"></p>



<script>

obj = {"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567","MC":"Yes"};

//var obj=fd.field('JSON').value();

document.getElementById("demo3").innerHTML =

obj.name + "<br>" +

obj.street + "<br>" +

obj.MC + "<br>" +

obj.phone;

</script>



</body>

</html>

Re: JSON

Posted: 22 Oct 2015
by rostislav
Hello! If your field is a multiline plain text field, then yes, that's how you'd retrieve the value. The only thing that's left to do is parse the string value into an object, like this:

Code: Select all

var obj = JSON.parse(fd.field('JSON').value());

Re: JSON

Posted: 22 Oct 2015
by Sebastian Haugland
Thanks but I still can make it work for a multiline field - it works for a single line text field

Re: JSON

Posted: 22 Oct 2015
by Sebastian Haugland
Thanks but I still can't get it to work for a multiline field - it works for a single line text field

Re: JSON

Posted: 22 Oct 2015
by rostislav
The term "multiline text field" is ambiguous in SharePoint 2010. There are at least three types. The way you're accessing it would work for a plain multiline text field, but not for the other two. Refer to this page to see how to access a field with regards to its type http://formsdesigner.blogspot.com/2013/ ... -form.html

If indeed you're trying to access a multiline plain text field then we can schedule a Team Viewer session to sort out your problem.

Re: JSON

Posted: 26 Oct 2015
by Sebastian Haugland
Yes... but working now :) I wanted a mulitline field to be able to store (JSON) more than 255 chars, but as I mention it did not work - but after I changed the field from 6 lines of editing (standard) to 1 line in Sharepoint it works :)