My Products
Help
omelhus
PARTNER

Issue with joinup when the foreign key is 0

by omelhus

Hey,

 

So we have an issue when I have a joinup_Associate_via_Employee on e.g. order, and employeeNo is 0, it will joinup the first associate that's not an employee.

 

Any way you could add a check to see if the foreign key on the join is actually set?

 

Cheers!

4 REPLIES 4
Accepted solution
Marius Bancila
VISMA

by Marius Bancila (Updated ‎26-09-2024 21:57 by Marius Bancila VISMA )

Working on a fix.

For a query like:

query read_orders($cid : Int!)
{
  useCompany(no : $cid)
  {
    order(first: 10)
    {
      items
      {
        orderNo
        orderDate     
        
        customerNo
        supplierNo
        employeeNo
        
        joinup_Associate_via_Customer
        {
          customerNo
          supplierNo
          employeeNo
          name
        }
        
        joinup_Associate_via_Supplier
        {
          customerNo
          supplierNo
          employeeNo
          name
        }
        
        joinup_Associate_via_Employee
        {
          customerNo
          supplierNo
          employeeNo
          name
        }        
      }
    }
  }
}

The results will be as follows:

 

{
  "data": {
    "useCompany": {
      "order": {
        "items": [
          {
            "orderNo": 1,
            "orderDate": 20210212,
            "customerNo": 10002,
            "supplierNo": 51004,
            "employeeNo": 0,
            "joinup_Associate_via_Customer": {
              "customerNo": 10002,
              "supplierNo": 0,
              "employeeNo": 0,
              "name": "Me AS"
            },
            "joinup_Associate_via_Supplier": {
              "customerNo": 0,
              "supplierNo": 51004,
              "employeeNo": 0,
              "name": "Abc AS"
            },
            "joinup_Associate_via_Employee": null
          },
          {
            "orderNo": 2,
            "orderDate": 20130203,
            "customerNo": 0,
            "supplierNo": 0,
            "employeeNo": 0,
            "joinup_Associate_via_Customer": null,
            "joinup_Associate_via_Supplier": null,
            "joinup_Associate_via_Employee": null
          },
          {
            "orderNo": 3,
            "orderDate": 20130401,
            "customerNo": 10004,
            "supplierNo": 0,
            "employeeNo": 0,
            "joinup_Associate_via_Customer": {
              "customerNo": 10004,
              "supplierNo": 0,
              "employeeNo": 0,
              "name": "You AS"
            },
            "joinup_Associate_via_Supplier": null,
            "joinup_Associate_via_Employee": null
          },

 

omelhus
PARTNER

by omelhus

Perfection!

by Marius Bancila (Updated ‎26-09-2024 17:29 by Marius Bancila VISMA )

Your observation is correct. The result is not as expected. My only comment is that it joins the first associate that has employeeNo set to 0, which of course is not an employee (should be a customer or supplier), as you mentioned. 

We are looking for a solution to fix this problem.

omelhus
PARTNER

by omelhus

Thank you. I’ve worked around this by automatically fetching the columns from ToColumns on the relation and checking them for 0.