JSON

Discussions about Forms Designer for SharePoint 2010.
Locked
User avatar
Sebastian Haugland
Posts: 43
Joined: Fri Sep 19, 2014
Contact:

21 Oct 2015

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>

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

22 Oct 2015

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());

User avatar
Sebastian Haugland
Posts: 43
Joined: Fri Sep 19, 2014
Contact:

22 Oct 2015

Thanks but I still can make it work for a multiline field - it works for a single line text field

User avatar
Sebastian Haugland
Posts: 43
Joined: Fri Sep 19, 2014
Contact:

22 Oct 2015

Thanks but I still can't get it to work for a multiline field - it works for a single line text field

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

22 Oct 2015

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.

User avatar
Sebastian Haugland
Posts: 43
Joined: Fri Sep 19, 2014
Contact:

26 Oct 2015

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 :)

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests