Issue with creating related record from script
I have a Combox that a user can apply "Tasks" to the Client they are working with and normally that occurs from a Triggered Update within a form in the Clients Table. I've also been wanting to apply a task as a follow-up to that client when the Project closes out, which means the Trigger Update executes in the related Project table however creating the connection between the Task and the Client is failing and normally this occurs with the line in Red. Specially it doesn't like the reference to the Clients table, since I assume that is because it's not being triggers from within that table. I've tried some let statements, Clients.Clients, and can't seem to figure this out. I am hoping the explanation can highlight my error and someone has guidance?
Subset of script for the Task Creation below:
for items in select 'Task List Items (Template)' where 'Tasks Lists' = task_list do
let newTask := (create Tasks);
newTask.(Task := items.Name);
newTask.(Clients := thisProject) ;
newTask.('First Name' := cfn);
newTask.('Task List Items' := items);
newTask.('Due Date' := ncd)
end
8 replies
-
In the table Tasks, what is the name of the reference field to Clients?
-
The Field Name that was for the Linked Table is 'Clients' and I named the reference field 'Client' since the person was picking one, and it error'd. I renamed it 'Clients' and same error and for clarity the fully qualified name would be Trips.Client and Trips.Clients since the script is within the Trips form, and Clients table is a Link From relationship.
-
Holly M said:
for clarity the fully qualified name would be Trips.Client and Trips.ClientsIt doesn't matter what table we start in since you are in the Tasks table when you create a new record (line 1). So any troubleshooting has to be done from the Tasks table.
let newTask := (create Tasks); newTask.(Task := items.Name); newTask.(Clients := thisProject) ; newTask.('First Name' := cfn); newTask.('Task List Items' := items); newTask.('Due Date' := ncd)
So you need to match the name of the field in line 3 to the appropriate field name in the table Tasks.
If you have matched the name and Ninox still errors out then try copying and pasting into a formula field or button and see if it still errors out. Or cut out line 3. Save the changes. Close the edit window. Then go back to edit the formula and try typing in line 3 again. I've noticed sometimes Ninox can't get the right path sometimes.
-
Thanks Fred and I made sure the field name in Tasks is 'Clients' and used your suggestion but the error is now showing on the ) which I haven't seen unless the ; is missing. I am using this code from within the Clients table just fine, it's from the Trips table but to your point the 'Clients' field does exist in Tasks.
let newTask := (create Tasks);
newTask.(Task := items.Name);
newTask.('Clients' := thisProject);
newTask.('First Name' := cfn);
newTask.('Task List Items' := items);
newTask.('Due Date' := ncd) -
Holly M said:
but the error is now showing on the )That is unusual. If possible can you post the full code? I'm wondering how thisProject is set.
-
Absolutely and the first is from the Clients table where I add tasks, and the script is working fine. and the second attachment is from the Trips table where I am getting the error.
-
The issue is with the variable thisProject. You have it set to "this". So of course it works in the Clients table, but when copied over to the Trips table it fails. It fails because the root table changes from Clients to Trips.
So you just need to extend thisProject to include Client and it should all be OK.
newTask.('Clients' := thisProject.Client)
Assuming that Client in Trips is the same as Clients in Tasks.
-
Bingo and thank you for the help, and also my continued learning of Ninox!
Content aside
- 1 yr agoLast active
- 8Replies
- 91Views
-
2
Following