This topic is locked
[SOLVED]

Getting the Value from field in the after record added event

1/24/2024 2:44:54 PM
ASPRunner.NET General questions
P
precisiondi author

I'm currently add a value to the database using this method sqlValues["columnName"] = value; in the before record added event and it is adding it as expexted. But I need to access the newly added value in the "After Record Added" event but I haven't been able to make it work using "values["ColumnNam"]" or using the DB.query like this:
Logging.WriteLogFile("SelectQuery: " + sql);
dynamic rs = DB.Query(sql);
XVar data;
while (data = rs.fetchAssoc())
{
string hostURL = data["hostedPageUrl"].ToString();
Logging.WriteLogFile("HostURL: " + hostURL);
}

Any suggestions or advice would be greatly appreciated

P
precisiondi author 1/25/2024

I was able to get it to work by using the following:

dynamic data;
dynamic rs = DB.Query(sql);
while(data = rs.fetchAssoc())
{
string HostURL = data["hostedPageUrl"];
string HostPageId = data["hostepageId"];

Logging.WriteLogFile("Returned URL: " + HostURL);
Logging.WriteLogFile("Returned HostpageID: " + HostPageId);
MVCFunctions.HeaderRedirect(HostURL);

}

E
Eric Chan 1/26/2024

Your approach is very interesting! And the manual is incompleted! It doesn't explain the usage of sqlValues in the manual.

I never use the sqlValues[] but values[] in the BeforeAdd event. After the record is added, it could be retrieved by values[] directly.