This possible without javascript? row action to remove value in reference field

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
I have a workaround where I set the reference field that isn't associated to anything anywhere called 
"No Upgrade". Really don't like this, but I need to continue with my work and get back to this later with a better solution.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
K. Now I have another location where I need a solution to this. I need to remove the reference in the reference field.

If I need a function, can someone please point me in the right direction. The fields that need to be blanked out are "Quote_Line_Item__c" and "BLND_Upgrade_to__c".
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Pat, You are correct that this does not work with the action framework right now. It's a bug. I think you are stuck using Javascript to update the row for now!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
As it's a bug, can someone please provide the javascript for this. Thanks.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Try something like this. BTW Pat can you explain how you have the rows in your tables turn yellowish when you hover over them? It looks really cool!

var params = arguments[0],	$ = skuid.$;
var model = skuid.$M('YourModelName');
var row = model.getFirstRow();
model.updateRow(row,{
// I'm not 100% sure that null is correct it might have to be an empty string or something...
YourLookupField: null 
});
model.save({callback:function(result){
if(result.totalsuccess){ // if the save went through
model.updateData(); // refresh the data on the page 
}
}});
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,674 Points 20k badge 2x thumb
That yellow hover thing was mostly made by Scott. I helped a tincy bit. He gave me the CSS for it. Here you go.

table.nx-skootable-data tbody tr:nth-child(even):hover:not(.nx-item-has-drawer) td,table.nx-skootable-data tbody tr:nth-child(odd):hover:not(.nx-item-has-drawer) td {
    background-color: #FFB700;
    color:white;
    font-weight: bold;}
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
It works!
Photo of Emily Davis

Emily Davis, Employee

  • 3,502 Points 3k badge 2x thumb
Thanks, Moshe! I think doing null or '' (the empty string) should work.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Moshe beat me to it...  

In your action sequence,  instead of an action of type "Update field on a row"  use the type "run Javascrip Snippet"  

In your resources your code can be as simple as this: 

$ = skuid.$;var model = skuid.model.getModel('YourModelName');
var row = model.getFirstRow();
model.updateRow(row, {ReferenceFieldName:''});

Moshe's code goes ahead and performs the model save action,  which is nice - but can also be done by the Action Framework. 

If you depend specifically on the success of this field blanking before moving to the next step you should read about the Deferred Promise approach.