Triumph-Tech / Triumph-Helix

A repo that allows for reporting issues related to Helix.
https://helix.triumph.tech
5 stars 0 forks source link

Modify Entity Does Not Return Object for New Entities #5

Open zackdutra opened 1 month ago

zackdutra commented 1 month ago

Description

When using modify entity with an Id of 0 to create a new entity, the ModifyResult does not contain the created object.

Actual Behavior

ModifyResult only contains the object for edited entities, not created entities. This means we don't have a way to get the Id or Guid of the newly created entity.

Expected Behavior

I would expect the object to be present using ModifyResult.Object, where "Object" is the entity name, such as ModifyResult.EventItem. This is important because it allows us to use the new Id without doing a more error-prone lookup of the most recently created entity.

Steps to Reproduce

Note that the success is true, but the Id is blank.

Issue Confirmation

Rock Version

16.6

zackdutra commented 1 month ago

I've also tried to reproduce this using the sample in the docs: https://helix.triumph.tech/lava-commands/db-transaction

{% dbtransaction %}

    {% modifygroup id:'0' %}
        [[ property name:'Name' ]]Ted's Traveling Circus[[ endproperty ]]
        [[ property name:'GroupTypeId' ]]26[[ endproperty ]]
    {% endmodifygroup %}

    {% modifygroupmember id:'0' %}
        [[ property name:'PersonId' ]]{{ CurrentPerson.Id }}[[ endproperty ]]
        [[ property name:'GroupId' ]]{{ ModifyResult.Group.Id }}[[ endproperty ]]
    {% endmodifygroupmember %}

{% enddbtransaction %}

{% if TransactionResult.Success == false %}
    <div class="alert alert-warning">
        <strong>{{ TransactionResult.ErrorMessage }}</strong><br>
        Validation Messages<br>
        <ul>
        {% for message in TransactionResult.ValidationErrors %}
            <li>{{ message.ErrorMessage }}</li>
        {% endfor %}
        </ul>
    </div> 
{% endif %}

The docs note that the code should not work because the group role id is missing. However, even with group role Id added, I get the error Error setting property GroupId to ''. Error: Input string was not in a correct format. Validation Messages

If you add a Debug, such as {{ ModifyResult | Debug}} you can see that the object is empty.

zackdutra commented 1 month ago

After using Helix for a few weeks, I've found this is the one issue that is the most limiting, as I've had to use sql or the API in place of having the ID of a newly created entity.

jonedmiston commented 1 month ago

We're working on an update to come out in the next few weeks.