Copy text field to reference field
Hi Brain Trust,
Is this possible?
I would like to trigger after update a text field (copy a text field) to a reference field. They are both in the same table.
The text field is populated from a Dynamic multiple choice field.
I would like to reference that choice.
Table1 has the following:
A text field named Data1
A reference field named DATA ITEMS
The text field in DATA ITEMS is named Data.
The reference fields DATA ITEMS and the Dynamic multiple choice field are pointed to the same table. Table2.
The Dynamic multiple choice field is located in another table. Table3
thanks for looking
18 replies
-
Most things are possible.
I'm a bit confused here. Do you have two dynamic Multi choice fields (dMC)? One in Table2 and one in Table3?
To clarify: you want to copy data from Table1:Data1 to Data Items:Data when changes are made to Data1?
And changes are made to Table1:Data1 from a dMC that is in Table1?
-
The DATA ITEMS field is blank. The Data1 is populated. I would like them both to be populated when the trigger after update of Data1 is executed
-
Since Table1 has the reference field to Table2 (called Data Items) that means there is a 1 to many relationship between the tables, 1 record in Table2 has many related records in Table1.
Do you want the Data Items:Data to be updated with all of the data from Table1:Data1 as you add more records in Table1? Or do you want the last record in Table1 to have the final say in what is in Data Items:Data?
How are Table1 and Table3 related? How does the dMC in Table3 update a record in Table1? Can you post the code in the Trigger for the dMC?
-
Sam said:
let j1 := (create Table1);
j1.(Data := i.Data);
j1.(Table3 := xCurrRec)Question: is there a reason why you don't create the link to table2 when you create the records in the dMC trigger? You can add:
let j1 := (create Table1); j1.(Data := i.Data; 'Data Items' := i; Table3 := xCurrRec)
Or is the link created in some other way?
-
Sam said:
Fred I think it may be linked through the dMC ‘Other Data’
The Dynamic value is:
let xTemplate := number (‘Other Data’);
(select Table2)[‘Other Data’ = xTemplate]dMCs do not create a hard link between records, unlike reference fields. They make more of a "soft link" between records. You have to use number(dMC) or record(tablename,number(dMC)) to get the full record.
Sam said:
The text field is populated from a Dynamic multiple choice field.
I would like to reference that choice.If you are talking about the dMC in table3 that is used to create the records in Table1 then you can if you create the link in the reference field Data Item when you first create the records in table1. Thus my question about why not create the link to Table2 (Data Item) when you create the Table1 records.
Does this make sense? I'm getting a bit confused talking about it.
So back to your original question. You can do something as simple as this in the trigger of Data1:
let t := this; 'DATA ITEMS'.Data := t.Data1
And this will copy the data from Data1 to Data in the table 'Data Items'.
Just be aware that subsequent Table1 records that are linked to Table2 will overwrite the previous copy. Will you have multiple records in Table1 linked to a single record in Table2?
-
Sam said:
Fred Will you have multiple records in Table1 linked to a single record inTable2?
yesSo you can try this:
let t := this; let newData := 'DATA ITEMS'.Data + " " + t.Data1; 'DATA ITEMS'.Data := newD
Now we create a new variable that gathers the data from the Data field in Table2 then adds a paragraph break then adds the data from the Data1 field of the current record.
Then we copy the data of the new variable into the Data field of Table2.
Content aside
- Status Answered
- 2 yrs agoLast active
- 18Replies
- 134Views
-
2
Following