Forum Discussion

AndrewFry's avatar
AndrewFry
Qrew Assistant Captain
6 years ago

Bring down list of available contacts based upon selected client

I have a tried to get this right and keep running into a few issues. I was hoping to get an additional brain or two to look at this.

I have the following tables:
  • Work Orders
  • Clients
  • Contacts
  • Jobs
  • Assignments
The relationships are as follows:
  • Clients < Work Orders
  • Clients < Contacts
  • Contacts < Work Orders (x7, one for each contact type)
  • Work Orders < Jobs
  • Jobs < Assignments
In my Work Orders table, I have a dropdown to select from a list of available Clients (based off of the Clients table).
I also have a number of drop downs for the various contact types.
Once I select the Client, the contact type drop downs are selectable, and only show a list of contacts from the client previously selected, matching the contact type for that field, i.e. Home Owner, Manufacturer, Supervisor, etc.
It works great.

However, I now need to have a single contact dropdown in my Assignments form. It will list all contacts, regardless of type, for the client selected in the related work order.

I thought I had figured it out but it isn't working.

I brought the Related Client down from Work Orders through Jobs to Assignments.
I created a Relationship between Assignments and Contacts (Contacts < Assignments).
I made the Assignment's Contacts dropdown be conditional based upon the Job - Work Order - Related Client.

I start a new work order, I selected the client, I  click "Add Job" from within the work order form.
It saves the work order and then opens the Add Job form.
I go to the Assignments Grid Edit within the Add Job form to add a corresponding contact to the Assignment.

I get an error message indicating that I first need to select a Job - Work Order - Related Client.
There is a Job - Work Order - Related Client column in the grid edit, but it is not selectable, and gives an error of: This is a lookup field.
Interestingly, I never added that Job - Work Order - Related Client field to the grid edit. It auto-added, and my attempts at removing it visually have been unsuccessful. I am assuming that it is present due to the Assignments' contact field being reliant upon the conditional factor set and related to the Job - Work Order - Related Client.

However, if I save the job, then go back in and edit it, the assignment now has a number in the Job - Work Order - Related Client and will allow me to select from all related contacts for that client.

So I think there is something broken with how I have it set up, in that it isn't pushing the related client from the work order through the job to the assignment, even though the work order gets saved with a client selected before accessing the "Add Job" from. It only updates once I save the job.

I really am at a loss on how to fix this. I have been tinkering but can't seem to get it right. I feel like I am very close, but am missing a key aspect to correctly fix it.

Any input anyone can give is greatly appreciated and will help to nudge, push, or throw me in the right direction.

Oh,. and also, thanks for reading my novel.


------------------------------
Andrew
------------------------------
  • AndrewFry's avatar
    AndrewFry
    Qrew Assistant Captain
    Ok, so I think I might have figured out part of the issue is.

    I am passing the Related Client from the Work Order through the Job to the Assignment.

    However, the Assignment form/report is a grid edit within the Jobs form.

    So when I am adding a new job, that particular job hasn't been generated yet, meaning the record hasn't been generated yet and thus cannot pass down the Related Client to the Assignment.

    To complicate things, the Assignment, like mentioned above, is a grid edit report embedded within the jobs. 

    I would have to save the job first, thus generating the record, and then it would be able to pass down the Related client to the Assignment.

    But that defeats the purpose of having the Grid edit in the jobs, to be able to input all the job and multiple related assignments, in one go, without having to save and go back.

    Any thoughts or ideas on how I could implement what I am shooting for, but not have to re-do my form structure?

    ------------------------------
    Andrew Fry
    ------------------------------
    • AndrewFry's avatar
      AndrewFry
      Qrew Assistant Captain
      I thought about creating a relationship between Work Orders and Assignments to bring the Related Client directly into the Assignment .... but that just seems "lazy" and perhaps incorrect.

      ------------------------------
      Andrew Fry
      ------------------------------