Hello,
I have a calendar with several fields but lets focus on two of them:
category (HTML type is SELECT; SQL type is TEXT)
letter (HTML type is TEXT; SQL type is TEXT)
category field has its values feed by automatic Lookup code listed below:
SELECT Title
FROM Projects
ORDER BY Title
Based on the category selected by the user at the time of event creation, I want to make a SQL query to autofill another field of my calendar, the field is called letter
In order to achieve that I went to my calendar events area, onValidadeSuccess and tried the following code:
{letter} = a;
Everything worked well and for that event being created, the letter value was a at the calendar table.
Next, I replaced the above code with something that would check for the category got by user and pick a letter value on Projects table. Find the code below (also in OnValidateSuccess of calendar):
$test = “SELECT letter FROM Projects WHERE Title = ‘{category}’”;
sc_exec_sql($test);
$test = {letter};
Both letter and Title fields in Projects table are HTML type TEXT and SQL type TEXT.
However, this code does not add anything to the letter field on my calendar.
I don’t have much experience on SQL and can’t see my mistake.
Thanks in advance for helping.
Daniel.