I want to do this
get value from multiple select as newRefs;insert into table1 ('name') values ('pete');SELECT LAST_INSERT_ID() as newUserId;for each (currentRef in newRef) { insert into lookupTable1 (userId,ref) values (newUserId,currentRef);}
Actually there is a quicker way to do this with MySQL/MariaDB as noted here https://dev.mysql.com/doc/refman/8.0/en/insert.html
What do I need to do this?Do I use Data Store Entities, Record Types, etc.?I can't be the first one that want to do something like this.
Discussion posts and replies are publicly visible
I am not sure I understand what you try to do. Can you add a bit more details please. What did you try in Appian?
Sure.I have a multi select drop down, where the value of each drop down is the primary key of a table.
As well, I have a 'New Item' form which contains various inputs/controls.
I need to have Appian first create the new item, then get the primary key of the record that was just inserted and finally I need to add to a lookup table the primary key of the new record and the values from the multi-select dropdown.
That is part 1 adding new items.
Part 2 is similar, but it's for editing items with the possibility of the selected values in the multi-select changing when updates occur.
I know how to do all of this in a tradition programming environment (C#, Java, etc.) which only takes me about 30 minutes to do.Maybe in Appian I need to setup a MySQL/MariaDB Function/Stored Procedure?
You should be able to use two separate Write Records nodes. You're correct that you cannot write too different record types within one Write Record node, but you can use two consecutive nodes to achieve what you're looking for! Like Stefan said though, just make sure you map the output from the first node so you can reference that foreign key in your second Write Records node.
Are you able to point me towards any help/documentation/tutorials on how to do this?
Sure! Here's a pretty good example in the documentation: docs.appian.com/.../Write_Records_Smart_Service.html
I've made some progress, using the example provided, however, for some reason the value is null/empty as shown in this Loom video:https://www.loom.com/share/9581aea2c2604eeb82499e94cac12da1It looks like I'm doing everything correct, so what am I missing?
Could it be that you do not store the "stored values" from the outputs tab of the first write records node back to the PV?
I suggest to do one step after the other, and also validate each step.
Assign the data coming from the interface to PVs -> Does this data show up?
Store data to the record -> Does it show up in DB?
Store stored values back to PV -> Does it do that?
.
Once you are more familiar with Appian, you might be able to skip a step or two. But even I, after 13 years do not do more than two or three steps without test and validation.
Personally I'm going to call this a bug, even though it's probably not, but after 10+ hours of trying to getting something done which can be done in 30 minutes or less in C# or Java seems like a bug/problem to me.You can see that the record is saved, but itemId a process variable never gets it's correct valueIt's a pretty simple process model as shown below, and the process variable is being set on the Outputs tab of the note.I've taken out the second write records to make this model even more simple
In your screenshot, you reference the value from the process variable and write it to itself. This is like
javaVariable.id = javaVariable.id;
This will also not change much.
Remove that assignment from the inputs tab. Then go to the outputs and store that value from ac!storedValues to your process variable.
Keep in mind that any "save into" assignment on both tabs will evaluate at the same time. You cannot rely on one assignment happening before the other.
This is not valid
So I have thisIn the Outputs tab I haveHere are the process details, note that the highlighted parts do not have the record Id field value, which they should.
Your output config is wrong. Store the data from Results -> "Records Updated" to your PV as only this includes the data coming back from DB after insert.
Having thisStill does not change the end result.ItemRecord still does not have the field with the value for the primary key and ItemId still does not have the value for the primary key.I'm not typing these values in, I'm selecting them.Are you staying that I need to supply a prefix e.g. pv! to the variables?
Your first screenshot looks good as will work. At least if there is no error in the DB when inserting the data.
Your second screenshot does not work. pv!record is the data that you want to store to the DB. The data coming back from the DB is ac!RecordsUpdated.
I suggest to remove the config from the second screenshot and make sure that the most simple config works. Just follow the examples (https://docs.appian.com/suite/help/22.4/Write_Records_Smart_Service.html#examples).
This is really dead simple, it just takes a bit of getting your head around it and forget all the Java and C# relics.
Okay, let's talk about this step from the sampleI have thisAnd ItemRecord does not have the primary key field or value.In the documentation they say that the person variable has both the primary key field and value.I can easily accept that I'm wrong, but it would seem that when I follow their example I don't get the expected result.
Maybe a stupid question, but how does your record data model look like? Does it include an auto-generated primary key field?
Here's the table structure, as you can see the primary key is an AUTO_INCREMENT fieldDoes this need to be enabled as well
If so then Appian is doing extra work behind the scenes then it needs to.MySQL/MariaDB is perfectly capable to both keeping track of the auto increment field type and doing the addition when it needs to.
You will need to enable that as well. As I already said, you will need a bit of time and trial/error to adapt your way of solution design to Appian. Think of Appian being the heart of your app, and the DB becomes just a dump data storage.
There does not seem to be a way to add a sequence to a record type which has been created from a MySQL/MariaDB table. I don't have any to choose from and what I found on the Appian site was information about Oracle when first creating the record type.Maybe I have to use Data Stores Entities somehow?
Do not go back to Data Stores. Records are the way forward. Is this a synced record?
Where are you on your Appian voyage? Did you attend some of the online trainings? Did you implement the tutorials (https://docs.appian.com/suite/help/22.4/Tutorials.html)?
The record is synced.I have gone over the Appian Academy +> Appian Developer => Learning Path, not too recently and I've done a number of other courses on academy.appian.com
This SHOUD be pretty simple, but for whatever reason this is not working.I'll go back to what I said previously, this appears to be a BUG.This is pretty darn silly, 15+ hours just on something like this.I thought that one of the benefits of Appian/Low Code was quick development.I'm pretty sure that had I used SpringBoot for the backend and React for the frontend development that this could be done in that same 15+ hours.
Given that I'm using the free community edition in the cloud there is little I can do to see what is actually happening in the background.I guess I'll look into creating a Stored Procedure/Function in the MySQL/MariaDB database providing Appian can execute them.
And, according to one or two posts on this site one should not use a stored procedure to write data to a database using Appian as this could result in extra database writes.seehttps://community.appian.com/discussions/f/process/12806/is-there-any-way-to-call-a-stored-procedure-having-some-input-parameters-that-updates-writes-to-db