Get Row By Id Issue

  • 1
  • Problem
  • Updated 6 years ago
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members. The community moderator provided the following reason for archiving: Old Forum Posts - bugs that have been fixed.

I have QuoteId available as a URL Parameter for a skuid page.
The Quote with the above quote id is also present in a quote table in the
same skuid page.

The model name of the quote is QuoteData.

My snippet is trying to retrieve the quote details and appending it to a
field in another model.

    var field = arguments[0],
        value = arguments[1];

    var quoteId = skuid.page.params.QuoteId;
    var quoteModel = skuid.model.getModel('QuoteData');
    var quote = quoteModel.getRowById(quoteId);
    alert(quote.Number);
    alert(quote.Id);

But the Quote Number and Quote ID values are empty. What am I doing wrong?


Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
  • confused

Posted 6 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 54,014 Points 50k badge 2x thumb
Is QuoteId a 15-digit Id? getRowById is expecting an 18-digit Id. 
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
18 Digit [0Q0i0000000amqACAQ]

Photo of Ben Hubbard

Ben Hubbard

  • 12,710 Points 10k badge 2x thumb
Hi,

Your code seems like it should be working.  One thing that you could check is that you're actually getting the quote id from the skuid.page.params object.  This object is case sensitive, so you have to name it exactly as it appears in the url of your browser.  Instead of doing alert('text'), I like to do console.log('text'); and then check my browser's javascript console for the results.  I would try something like this to help debug.  Browsers like Chrome and Firefox have really good inspectors so you can see the contents of entire objects when you log them using console.log.

    var field = arguments[0],
        value = arguments[1];
    console.log('Skuid Page Parameter Object...'); console.log(skuid.page.params); console.log(skuid.page.params.QuoteId); var quoteId = skuid.page.params.QuoteId;   
    var quoteModel = skuid.model.getModel('QuoteData'); console.log('QuoteData Model...'); console.log(quoteModel);     var quote = quoteModel.getRowById(quoteId); console.log('Quote Row...');
    console.log(quote.Number);
    console.log(quote.Id);
Can you post the results that are coming from your console with these console.logs included?
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
Interesting thing to note is that javascript alert does not show the values however the values
show up when I perform a console.log. So i went ahead and assigned that value to the related model field.

var field = arguments[0],
        value = arguments[1];

    var quoteId = skuid.page.params.QuoteId;
    var quoteModel = skuid.model.getModel('QuoteData');
    var quote = quoteModel.getRowById(quoteId);
   
    var dt = field.metadata.displaytype;
    if (field.mode != 'edit') {
        skuid.ui.fieldRenderers[dt][field.mode](field,value);
    } else {
        skuid.ui.fieldRenderers[dt].edit(field,value);
    }

    field.model.updateRow(field.row,'Description',quote.Number);
   
    if(field.mode=='edit')
      field.element.find('input').val(quote.Number);
     
    console.log(field);

The field is a description field of the Task Object. Even though the field
gets updated and the Comments (Description field) show up correctly in
SFDC pages ( http://i.share.pho.to/fc0ba470_o.png )

However Skuid does not display the Description field of the Task Object.
I tried removing the snippet from the Description field and hoped it would
read the value from SFDC. It didnt. 

For some reason description is not even editable even though it is
not set as Read Only in the properties.

http://i.share.pho.to/14f92604_o.png

Looks like a bug??



Photo of Ben Hubbard

Ben Hubbard

  • 12,710 Points 10k badge 2x thumb
Hi, can you send the xml of your page to me at ben@skuidify.com ?  Thanks!
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
Benn, I have sent the xml of the page to your email. I have highlighted necessary sections of the xml so that you may identify the relevant portions of the xml.
Photo of Ben Hubbard

Ben Hubbard

  • 12,710 Points 10k badge 2x thumb
Thanks Santosh, It looks like you're not using the standard renderer in your "newSnippet" snippet.  So nothing will show up there and no input element will be found by your element.find('input') command.  I think you need something like this...

// Run the standard renderer
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);

... before you can search the field's element for any input fields.  If you change the description "field renderer" property back to "standard", it should pull in the description just like the standard SFDC page.
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
Perfect. That works.
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
Perfect. That works.   Actually I did set the standard renderer. See the above code.
Somehow Skuid did not save the snippet updates when I clicked on save.  Sometimes clicking save on the page design mode never completes and I lose all the changes.
Photo of Ben Hubbard

Ben Hubbard

  • 12,710 Points 10k badge 2x thumb
Ok, I think i've seen that happen before. Does the "Saving" button just sit there without going away? If that happens to you again, and you post the errors that show up in the javascript console. I think this happens if you were inactive for a while and then try to save a skuid page when your session has expired.
Photo of Jaust

Jaust

  • 462 Points 250 badge 2x thumb
Thats correct.. The page is stuck at "Saving".. Will try to take the snapshot of the javascript console the next time it happens

This conversation is no longer open for comments or replies.