Skip to main content
August 22, 2023
Question

How to use conditional basis entity data in write to multiple data store entity

  • August 22, 2023
  • 10 replies
  • 0 views

I have two process variable that is CDT type.

I need to if any of the process variable is null then related to that process variable entity data not executed.

Like this: 

= {  

 if(    a!isnotnullorempty(pv!dependencies),   

         null,   

a!entityData(   

         entity: cons!DSE_COMMUNITIES, 

        data: pv!communityAllocation  )

),

    if(    a!isnotnullorempty(pv!dependencies),   

         null,   

       a!entityData(     

         entity: cons!DSE_DEPENDENCIES,     

         data: pv!dependencies    )  )}

But it gives error:

An error occurred while trying to write to the data store [Tables]. No values have been written. Details: org.hibernate.PropertyValueException: not-null property references a null or transient value DependenciesDT21866.projectid (APNX-1-4208-004)

Please, anyone suggest........

    10 replies

    nileshr5443
    August 22, 2023

    By looking at your code it looks like you have added wrong condition. iT should be like if that variable is null then don't do anything else write to DB like below. Also in both if condition you are checking same variable but writing to different entity. Please try the below code and see if it is working.

    = {  

     if(    a!isnullorempty(pv!communityAllocation),   

             null,   

    a!entityData(   

             entity: cons!DSE_COMMUNITIES, 

            data: pv!communityAllocation  )

    ),

        if(    a!isnullorempty(pv!dependencies),   

             null,   

           a!entityData(     

             entity: cons!DSE_DEPENDENCIES,     

             data: pv!dependencies    )  )}

    August 22, 2023

    Thank you for reply.

    I tried your code but It gives same error as previous.

    Error:

    An error occurred while trying to write to the data store [Tables]. No values have been written. Details: org.hibernate.PropertyValueException: not-null property references a null or transient value : DependenciesDT21866.projectid (APNX-1-4208-004)

    August 22, 2023

    In the database table you're working with, there's a specific field that has been configured to not allow null values. Please ensure that your primary key (PK) is set to auto-increment. This step will address the problem if the PK is null. Otherwise, review the table's structure to identify the specific column responsible for this issue.

    mikes0011
    Brainy
    August 22, 2023

    If you don't have anything to write for a particular Entity entry, you will need to set that list item to EMPTY SET ( {} ), because NULL() actually carries a value and will cause the node to error.

    This makes some assumptions into the validity of your null checks.  The second null check (for pv!dependencies) seemed backwards so I switched to the opposite rule (since you wouldn't be writing pv!dependencies if it's actually empty).

    {
      if(
        a!isNotNullOrEmpty(pv!dependencies),
        {},  /* null, */
        a!entityData(
          entity: cons!DSE_COMMUNITIES,
          data: pv!communityAllocation
        )
      ),
      if(
        a!isNullOrEmpty(pv!dependencies),  /* note, switching the null check rule used here */
        {},    /* null, */
        a!entityData(
          entity: cons!DSE_DEPENDENCIES,
          data: pv!dependencies
        )
      )
    }

    August 23, 2023

    Thanks for reply.

    By putting empty set with your code, it still gives same error as above..

    mathieud0001
    August 23, 2023

    Care to show the values of the PVs?