2

I have a SharePoint list that I'm querying using Javascript and JSON. I have two choice columns called LifeCycleStatus and Priority.

The results for LifeCycleStatus is coming back fine, but for Priority it's coming back [object OBJECT].

I'm pretty new to JavaScript and JSON so I think it's something to do with the var query, can you query two choice columns in the same string?

 var query = "http://collaboration-dev.norgine.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&Priority&$filter=Id eq " + window.DeviceId + "";

The rest of the code which relates to the Priority column is:

   var txtTrafficlight = "";

   var DevicePriority = item.Priority;

    txtTrafficlight = "<p>" + DevicePriority + "</p>";

    $('#devicestatus').append(txtTrafficlight);
  • You can check by placing debugger in console of browser window. You will find different choice properties for your field which you want to display. – Pradip R. Jun 15 '17 at 11:02
  • I don't think the choice properties are the issue. I know what they are, red, amber, green. The question I have is why is the query string returning [object OBJECT] ? – Dazza Jun 15 '17 at 11:12
  • Check in the debugger to see what the object actually is... Also, can you show how you use LifeCycleStatus? – JanErikGunnar Jun 15 '17 at 11:22
  • Its out of the box behavior for the specific type of field. You need to look more deep in that object to get actual value. – Pradip R. Jun 15 '17 at 11:23
  • Cheers, is there an article around on how to do that? I'm still pretty new to this! – Dazza Jun 15 '17 at 11:27
1

"Priority" and "LifeCycleStatus" contains an object. You can use the debugger/console to see what the object is - I bet it contains a string with the Value, and the internal ID of the value, possibly other things. Converting an object to a string returns "[object Object]".

"PriorityValue" and "LifeCycleStatusValue" are probably shorthands to the value string.

  • 1
    Yes, Better use Debugger tools (F12) and see what object contains. – DvG Jun 15 '17 at 12:59
1

Learn to use the F12 developer console and console.log() statements.

You only get [Object Object] when you try to display the value in HTML or use alert( )..

Trace to the F12 console and you will see the contents

If you get JSON from a server you can also see the result in the F12 Console Network tab (when you reload the page)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.