Skip to main content

Hi Team,

There is a requirement in mobile application. Client wants me to add save button instead of Add button. Now add button is also for save the data. So, could you please suggest how to do that.

 

please find the attachment below for reference.

 

Thank you in advance

HI @aishwarya 

You could add a custom field and make it of type button.

Then attach a client script to the control event.

Cheers!


Hi @Shneor Cheshin 

Thank you so much for your response. Let me try this

 


Hi @Shneor Cheshin 

I have tried and i added custom filed and written a client script. But the problem is data is not inserting into the table. below added my script. Please suggest any changes required or else suggest me the correct query.

 


var user_def12 = getControlValue("Escalation", "user_def12");
var user_def5 = getControlValue("Escalation", "user_def5");
var user_def7 = getControlValue("Escalation", "user_def7");
var user_def8 = getControlValue("Escalation", "user_def8");
var user_def9 = getControlValue("Escalation", "user_def9");
var user_def22 = getControlValue("Escalation", "user_def22");
var user_def23 = getControlValue("Escalation", "user_def23");
var user_def11 = getControlValue("Escalation", "user_def11");
var user_def13 = getControlValue("Escalation", "user_def13");
var user_def24 = getControlValue("Escalation", "user_def24");
var escId = getCurrentKeys("Escalation", "esc_id");
var rowId = getDBValue(stringFormat("select metrix_row_id from escalation where esc_id = '{0}'", escId));
var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = '{0}'", rowId));

// Add fields to the data transaction
taskTrans = addToDataTransaction(taskTrans, "metrix_row_id", rowId);
taskTrans = addToDataTransaction(taskTrans, "esc_id", escId); 
taskTrans = addToDataTransaction(taskTrans, "user_def4", user_def12);
taskTrans = addToDataTransaction(taskTrans, "user_def5", user_def5);
taskTrans = addToDataTransaction(taskTrans, "user_def7", user_def7);
taskTrans = addToDataTransaction(taskTrans, "user_def8", user_def8);
taskTrans = addToDataTransaction(taskTrans, "user_def9", user_def9);
taskTrans = addToDataTransaction(taskTrans, "user_def22", user_def22);
taskTrans = addToDataTransaction(taskTrans, "user_def23", user_def23);
taskTrans = addToDataTransaction(taskTrans, "user_def11", user_def11);
taskTrans = addToDataTransaction(taskTrans, "user_def13", user_def13);
taskTrans = addToDataTransaction(taskTrans, "user_def24", user_def24);

saveDataTransaction(taskTrans, getMessage("Escalation", "LABEL"));

Thanks in advance


HI @aishwarya 

A few things.

  1. Add sucess validation at the end of the script. This will help you to understand more.
    For example
    var saved = saveDataTransaction(taskTrans, getMessage("Escalation", "LABEL"));
    if (saved == true) {
    alert('Saved');
    } else {
    alert('Error Updating the Record!');
    }
  2. Change your methods to lowercase. Instead of var user_def22 = getControlValue("Escalation", "user_def22");
    Do var user_def22 = getControlValue("escalation", "user_def22");
  3. Change syntax in generateDataTransaction. I never saw wrapping the parameter with quotes.
    var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = '{0}'", rowId));
    To
    var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = {0}", rowId));
  4. Are there any errors on the server side? Check server logs. Increase the log level if necessary.
  5. Add debug points with the ‘alert’ method.
    For example
    var escId = getCurrentKeys("Escalation", "esc_id");
    if (isNullOrEmptyString(escId)){
    alert('escId ' + is empty);
    }

 

 

I hope this will help.

Cheers!


HI @aishwarya 

A few things.

  1. Add sucess validation at the end of the script. This will help you to understand more.
    For example
    var saved = saveDataTransaction(taskTrans, getMessage("Escalation", "LABEL"));
    if (saved == true) {
    alert('Saved');
    } else {
    alert('Error Updating the Record!');
    }
  2. Change your methods to lowercase. Instead of var user_def22 = getControlValue("Escalation", "user_def22");
    Do var user_def22 = getControlValue("escalation", "user_def22");
  3. Change syntax in generateDataTransaction. I never saw wrapping the parameter with quotes.
    var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = '{0}'", rowId));
    To
    var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = {0}", rowId));
  4. Are there any errors on the server side? Check server logs. Increase the log level if necessary.
  5. Add debug points with the ‘alert’ method.
    For example
    var escId = getCurrentKeys("Escalation", "esc_id");
    if (isNullOrEmptyString(escId)){
    alert('escId ' + is empty);
    }

 

 

I hope this will help.

Cheers!

Hi @Shneor Cheshin 

Below is the updated query but still data is not saving. in client script i have tested and found a error .Could you please suggest what i need to change here to insert data from mobile save button. When i am clicking on save button alert is comming but data is not inserting

var escId = getCurrentKeys("Escalation", "esc_id");

var user_def12 = getControlValue("escalation", "user_def12");
var user_def5 = getControlValue("escalation", "user_def5");
var user_def7 = getControlValue("escalation", "user_def7");
var user_def8 = getControlValue("escalation", "user_def8");
var user_def9 = getControlValue("escalation", "user_def9");
var user_def22 = getControlValue("escalation", "user_def22");
var user_def23 = getControlValue("escalation", "user_def23");
var user_def11 = getControlValue("escalation", "user_def11");
var user_def13 = getControlValue("escalation", "user_def13");
var user_def24 = getControlValue("escalation", "user_def24");
var escId = getCurrentKeys("escalation", "esc_id");
//var rowId = getDBValue(stringFormat("select metrix_row_id from Escalation where esc_id = '{0}'", escId));
var rowId = getDBValue(stringFormat("select metrix_row_id from Escalation where esc_id = {0}", escId));
var taskTrans = generateDataTransaction("Escalation", "UPDATE", stringFormat("metrix_row_id = {0}", rowId));

// Add fields to the data transaction
taskTrans = addToDataTransaction(taskTrans, "metrix_row_id", rowId);
taskTrans = addToDataTransaction(taskTrans, "esc_id", escId); 
taskTrans = addToDataTransaction(taskTrans, "user_def4", user_def12);
taskTrans = addToDataTransaction(taskTrans, "user_def5", user_def5);
taskTrans = addToDataTransaction(taskTrans, "user_def7", user_def7);
taskTrans = addToDataTransaction(taskTrans, "user_def8", user_def8);
taskTrans = addToDataTransaction(taskTrans, "user_def9", user_def9);
taskTrans = addToDataTransaction(taskTrans, "user_def22", user_def22);
taskTrans = addToDataTransaction(taskTrans, "user_def23", user_def23);
taskTrans = addToDataTransaction(taskTrans, "user_def11", user_def11);
taskTrans = addToDataTransaction(taskTrans, "user_def13", user_def13);
taskTrans = addToDataTransaction(taskTrans, "user_def24", user_def24);
var saved = saveDataTransaction(taskTrans, getMessage("Escalation", "LABEL"));
if (saved == true) {
    alert('Saved');
} else {
    alert('Error Updating the Record!' + user_def13 + 'hello');
}

 

Thank You in advance


Hi @aishwarya 

Besides a few minor syntax issues, I cannot say much.

 

You have this row twice. Is it returning the expected value?

var escId = getCurrentKeys("escalation", "esc_id");

Try using lower case in var taskTrans = generateDataTransaction("Escalation",

var taskTrans = generateDataTransaction("escalation",

This row seems redundant

taskTrans = addToDataTransaction(taskTrans, "metrix_row_id", rowId);

 

Cheers!


Reply