This topic is locked
[SOLVED]

 Issues with getNextSelectedRecord()?

5/11/2020 6:30:51 PM
ASPRunner.NET General questions
joglidden author

Has anyone had issues with getNextSelectedRecord()? I'm following the example in the documentation, "Email selected records", "How to send an email to a predefined address". The XVar object simply will not populate with an associative array. Every time an email is sent, the body is null. Here is my server code:



StringBuilder body = new StringBuilder();

XVar rmail = XVar.Array();
XVar tabledata;

while(tabledata = button.getNextSelectedRecord())

{

body.AppendLine

(String.Format(

"ID: {0} \n" +

"Data: {1} \n" +

"------------------",

tabledata["ID"], tabledata["Data"])

);

}
rmail["to"] = "xxxx@xxxxxxxx.com";

rmail["subject"] = "Records";

rmail["body"] = body.ToString();
var arr = MVCFunctions.runner_mail(rmail);
result["txt"] = "Emails were sent.";
if(!arr["mailed"])

{

result["txt"] = "Error: " + arr["message"].ToString();

}


It's pretty much identical to the example, except for changes to column names, etc. Has getNextSelectedRecord() been deprecated for something that functions better? If anyone has any ideas, it would be most appreciated.

joglidden author 5/12/2020

I have solved my issue, which is you need to be careful when deleting objects in Designer, and then you 'Re-insert deleted elements'. In between, I added my custom button code. Of course that would cause troubles, though I don't know exactly why. A better approach is to simply create a new similar page, re-insert deleted elements, add custom button code, and then delete the old page. I did this, and then it worked. I'm sure I'm the only person who will ever do this in this way, but there it is.