jSignature Custom Component - handleSave function issue

  • 1
  • Question
  • Updated 4 years ago
I've created a Signature custom component with jSignature (based heavily on Peter'.s work here - thanks, Peter!).

The problem I'm running into is that I want to be able to run updateRow on save, so that I can store the value from jSignature in SFDC appropriately.

When a save happens, I need to run something like this:
//Save signature            
var sigData = element.jSignature("getData", "base30").join(",");
var sigName = signatureModel.getFieldValue(signatureRow,'Name') || defaultName;
 
// update signature text field in database and save
signatureModel.updateRow(signatureRow, {
Name: sigName,
Signature_Date__c: skuid.time.getSFDateTime(new Date()),
 Signature__c: sigData
});
signatureModel.save();

However, if I throw that into the handleSave function on my component, I'm going to get an infinite loop of saves.

Can anyone think of a good way to handle this?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
NOTE: There's some extra stuff in there, but the basic idea is that I need to get  element.jSignature("getData", "base30").join(",") and save that as the value for the Signature__c field.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Why do you want to run updateRow on save? Seems like there would be a better way to architect this... 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Yes! There must be a better way. That's what I'm looking for.

In Peter's example using skuid's "Custom" component, he used a pagetitle with a button that called a snippet to run something like the code above. That's my starting point.

Perhaps I could for changes on the Signature__c field on the model and run updatedRow then?