Limit data() to changed cells only in preSubmit event
Limit data() to changed cells only in preSubmit event
In the preSubmit event, is there a way to have the data() returned show only the changed data and not the entire row(s)? I tried the submit
option of the form-options
object but that doesn't seem to limit the row().data() to only change the values in the preSubmit event. I know I can get the row's values prior to edit and then compare them in the preSubmit but if something is available to do this then I would rather use what is available. And since I am using this with Google Apps Script I am grabbing and submitting the edits in the preSubmit event.
Regards,
Karl S
This question has an accepted answers - jump to answer
Answers
Hi @Karl_S ,
The
formOptions
submit
property may help here - you can determine what to send based on what's changed. This example here shows that withinline()
,Hope that helps,
Cheers,
Colin
I guess I am not seeing the data that would be submitted as opposed to thew entire row of data. I have this and data() is showing me the entire row(s) information.
What you are looking for isn't something that Editor provides directly I'm afraid.
row().data()
will always get the original data object for the row - i.e. the whole thing.The best way to do what you want is to use
row().data()
in bothpreEdit
andpostEdit
and then do a diff between the objects (Lodash for example provides a method to do that, or use a small custom function). That would account for any changes to the data that the server-side has made.The alternative is to use the
data
object (third parameter) passed intopostEdit
to find the data for the row that was submitted to the server. If you havesubmit: 'changed'
then it will only contain the changed values.Allan
Thank you, Allan. I managed to get the things configured to have the form return only the changed values in the
postEdit
. This is actually exactly what I was looking for. I was just going about it the wrong way. Thank you for recognizing that possibility and getting me back on track!Karl S