I have a list with 2 columns Title and ID. I would like to get the Title based on a unique ID (101) value and insert it into a textbox Test. Here is my code:

<script type="text/javascript" src="/sites/Registry/SiteAssets/nanoajax.min.js"></script>
<script type="text/javascript" src="/sites/Registry/SiteAssets/sharepointplus-4.0.min.js"></script>
<script type="text/javascript">
$(function() {
$("input[id='Test_e9f98631-8894-4cc7-84c0-232a56c406c6_$TextField']").val( $SP().list("ListName").get({
  where:'ID = 101'
}) );

But instead of the value, the textfield is filled with "[object promise]" text. Is that possible to get somehow the value out of it or I should use a different approach?

Thank you very much for any suggestion!

  • 1
    You would typically use .then() on a promise to get its value. .get(...).then(function(val) {/* use the value here */ })
    – jfriend00
    Sep 27, 2017 at 18:19
  • May I ask you to adapt it for the sample code? The goal is to insert the value of the list into the textbox. I am sure, your instructions are clear, just I am new to js and even if I try not working well. Thank you!
    – Nefri
    Sep 29, 2017 at 8:10
  • I tryed like this: $SP().list("INN Lista").get({fields:"Title",where:'INNnumber = 101'}).then(function(result){$("input[id='Test2_e9f98631-8894-4cc7-84c0-232a56c406c6_$TextField']").val(result)}); But the result in the textbox is: "[object Object]".
    – Nefri
    Sep 29, 2017 at 8:22
  • If I think correctly, the result of the .get() is an object because there can be more then one element as the.get() result. (In my case only one value is the result). So the question is how to get that one value out of the object and insert into my textbox.
    – Nefri
    Sep 29, 2017 at 8:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.