I have a RecordType STG with multiple Records in it. I need to have that data inserted/copied to another RecordType TARGET. Both have the same columns and data types defined in them.
With the exception of Unique Identifiers (ID Column) in both the Tables, I want the rest of all columns data to be moved from STG to Target.
Can you please advise on how we can do this. I was thinking Script Task in a process model, but need some guidance on this.
Discussion posts and replies are publicly visible
You could create a rule (i.e. CopyRecords) that takes a list of the Record Type as input and returns a list of the target Record type:
a!localVariables( local!records: ri!S_Records_Source, local!recordsMap: cast( a!listType(typeof(a!map())), local!records ), local!recordsMapWithNoIdentifiers: a!update(local!recordsMap, { "id" }, { null }), cast( a!listType( 'recordType!{e10c73fb-040d-4dc2-bd0d-64ba11097acc}S_Record_Target' ), local!recordsMapWithNoIdentifiers ) )
Thank you Mathieu Drouin , I created an Expression Rule and I was getting error.
Expression evaluation error at function 'cast' [line 3]: Could not cast from RecordType to Map. Details: CastInvalidCould not cast from RecordType to Map. Details: CastInvalid
Am I missing something here? I have attached a screenshot of the Expression Rule I have used here.
1. Rule input needs to be an array.
2. You put the recordType object instead of a list of recordTypes. Should look like this.
Thank you Mathieu Drouin , I now have passed an Array of recordtype, I no longer am getting the error message. In the Output I don't see all the Record Types I was expecting, I was expecting to see around 12 Record Types in the output based on the Source data.
You need to pass the data (the result of a query) not just the record type.
Thank you Mathieu Drouin , I have passed in the result of the query now for the Source data. I do see 12 records in the Output, but for the 12 records, I only see 5 columns, I am missing most of the data points here. Any thoughts on this please.
Are the columns the same name (including casing) and type?
If not, you'll have to map them manually using a forEach like below
You are right Mathieu Drouin , you were spot on, I had both casing/naming issues. I have corrected them and now I am getting the correct output.
To capture that output and store it in the Target Table, I am planning on using a Script Task (Data --> Outputs --> Custom Outputs) within a Process Model as below, would that work? I am new to Appian and learning , please advise if my approach is off here?
a!localVariables( local!targetRecords: rule!VWHIAP_GET_TARGET_Review_List(), a!forEach( items: local!targetRecords, expression: if (1=1, saveInto: { a!writeRecords(records: local!targetRecords) }, "") ) )
a!writeRecords is only meant to be used in an interface.
For a Process Model, you will need a script task with your expression rule that you store in a PV and a Write Records node.
Mathieu Drouin Appreciate all your guidance and help on this. It is very helpful.