Query custom table using macro inside Forms Autoresponder

Mark Fasel asked on November 19, 2015 15:19

I have a custom form using Kentico form builder. In my form, I reference a custom table via a foreign key...meaning that my form stores the id that is a reference to my custom table data. In my auto responder is there anyway to retrieve the actual value from my custom table using the id value from my form?

Thanks!

Recent Answers


Brenden Kehren answered on November 19, 2015 15:30

I haven't tested this but it would be something like this. I'm not sure if Items[3] is simply the index or if it's the actual ItemID value, again, didn't test.

{% CustomTables["custom.tablename"].Items[3].GetValue("FieldName") %}
0 votesVote for this answer Mark as a Correct answer

Mark Fasel answered on November 19, 2015 15:45

How would this relate from say my ItemID in from the form to the table - ie how would i create that relation? Does that make sense?

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on November 19, 2015 15:57

You could create a custom macro function that you pass in the id of the form, and fetch the associated value from the custom table and return the value. I would think that Brendens above would return based on the index, and not the id of the form, but if it does use the id, then thats a pretty good approach! So try that first, and if it doesn't work, then you can create your custom macro funciton.

If your foreign key isn't stored by the form id, then the custom macro function may be necessary, as you won't be able to get the record that you need from the id.

Just use the Kentico api and fetch the custom table that you want and get your associated value.

https://docs.kentico.com/display/K8/Registering+custom+macro+methods

0 votesVote for this answer Mark as a Correct answer

Mark Fasel answered on November 19, 2015 16:03

yea, the foreign key is a different field in the form and not the form id. So to provide a little more specifics. I have a lookup table that is used for "time slots". In the form, the user can select a time slot however it stores it as the id in the form. So i am in the autoresponder, trying to get the actual value from that look up table. I hope that makes sense.

Thanks

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on November 19, 2015 20:19

So in the custom macro method, you would pass in the form id or if you have access to the custom table id field itself(which I believe you do), you can just pass that field in and the do a look up using the customtable api in Kentico. Then return the timeslot as a string, date, etc.

Does that make sense?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.