Skip to main content

Is it possible to assign the Name and other fields to a reference field via updateRow? This is a similar problem to showing the Name of a record instead of the Id when created a new row. I’m trying to do this with updateRow and am not having success.

My code:

modelA.updateRow({Id: firstrow.Id},
                {CheetahBMS__Serial__c: equipId,
                CheetahBMS__Serial__r:
                {
                    CheetahBMS__Serial__c: firstrow.CheetahBMS__dummysku__c,
                    CheetahBMS__Product_Group__r : 
                    {
                        Id:equip,
                        Name: prodname
                    }
                },
                CheetahBMS__Rate_Type__c: modelD.data resindex].CheetahBMS__Rate_Type__c,
                CheetahBMS__Order_Line__c: resID}
                ); 


I’m able to see in the dev console that these values are being updated in the model, but they are not showing up on my table until I save (which would happen even if I didn’t update the values).

I’m not trying to update the parent model values, just populate the table with the proper values. 

Just bumping this in case it was missed.

Thanks!


Craig - maybe you can back up and explain in more detail what you are trying to do. I’m not sure I follow your question.  Starting from a more specific use case may be more straightforward.


Craig, it absolutely is possible, check out this thread: https://community.skuid.com/t/populating-a-lookup-field-with-javascript-that-has-a-dis…


Moshe, that didn’t seem to work for me. I’ll try to take a step back and explain what I’m trying to accomplish and not assume everyone can read my mind! 🙂

The page is a check out/in page. There are two main objects here, Check_Out_Tickets__c and Products__c.The user creates a new check out ticket and scans the physical barcode on their product. This barcode represents the serial number (Serial__c on the Products__c object), which is not the same as the salesforce Id or the Name field for the product object. The page needs to process this serial number, show the name of the related parent “product group” (Serial__r.Product_Group__r.Name) on this checkout record and then create a new record in the check out model, allowing the user to quickly scan another barcode.

Currently, the system works like this:
-User start’s their scan session (creates blank row in Check_Out_Ticket)
-User scan’s the barcode which is dumped into a dummy field (dummysku__c on the Check Out object)
-JS code takes this dummysku__c, loops through all products to verify its a real product and to gather information about it, then populates the actual Serial__c field on the checkout object with the Id from the Products object.
-A new row is created by the hotkey (return - which is automatically pressed by the barcode scanner)
-Repeat process until the user is done, at which point they hit the save button which saves the Check_Out_Tickets that have previously been in edit mode.

This process works great and is lightning fast. I actually had to program in a half second delay because the barcode scanner was hitting enter too fast, and it appeared the browser didn’t recognize any text in the field. 

The issue is, I want to display the related product group name as the user is scanning. Currently they only see the dummysku field until they save that model, then it pulls in the field I’m trying to update (Serial__r.Product_Group__r.Name). The frustrating thing is, with the above code, I can see in the console log that the correct values are being added to the Serial__r.Product_Group__r.Name field, it just isn’t displaying it in the table until I save. 


Hi Craig,

I don’t think Skuid is smart enough (yet) to realize it needs to rerender your Serial__r.Product_Group__r.Name field. It’s just checking the top level fields in your updateData call. I think for now, you’ll need to manually rerender the field in question.

After your updateData statement, add this…


skuid.$.each(modelA.registeredFieldsByRowThenFieldhfirstrow.Id]t'Serial__r.Product_Group__r.Name'],function(){<br>&nbsp; &nbsp; this.render();<br>});


Keep in mind that your field may actually be Serial__r.Product_Group__c instead, I’m not sure exactly how you set up that field.  In that case, the code would be like this…


skuid.$.each(modelA.registeredFieldsByRowThenFieldyfirstrow.Id]['Serial__r.Product_Group__c'],function(){<br>&nbsp; &nbsp; this.render();<br>});


Let me know if this works.



Thanks for the response Ben. I actually figured out a solution this morning that works. I added the Serial__c reference field to the table as read only, and changed the display template to be {{Product_Group__r.Name}}, and this works perfectly without the forced rerender. 


Hah, that’s clever! Wouldn’t have thought to do that, but it’s a better solution.


Sometimes I get tunnel vision trying to solve my problem with JS I forget that the standard page editor also exists!