Unable to remove range from a data entity

Hi
I am trying to remove the ‘SalesType’ range from the SalesOrderHeaderV2Entity as I want to use the dual-write to create orders as journals.

When I pass in the SalesType as journal it is transformed to ‘Sales order’ in the SalesOrderHeaderV2Entity on creating the record because of the range which is set to ‘Sales order’.

Tried using this code but the datasource object is always null

[DataEventHandler(dataentityviewstr(SalesOrderHeaderV2Entity), DataEventType::InitializingEntityDataSource)]
    public static void SalesOrderHeaderV2Entity_onInitializingEntityDataSource(Common _sender, DataEventArgs _eventArgs)
    {
        QueryBuildDataSource    qbd;

        SalesOrderHeaderV2Entity salesHeaderEntity = _sender as SalesOrderHeaderV2Entity;

        FormDatasource          fb = salesHeaderEntity.dataSource();

        qbd = fb.query().dataSourceTable(tableNum(SalesTable));
        qbd.clearRanges();
    }

We duplicated the entity and removed the range and are able to create sales journal but since I want this for dual-write I have to use the standard entity.

I don’t think it’s possible. The range on SalesTable is not something added at runtime; it’s already in the view definition synchronized to database.

Thanks Martin,

Would it be possible to add another value to the range dynamically?

Sorry it’s related that’s why asking here.

I don’t think so. Many things happen by querying the view in database. Your extra range would have to be added to all such queries, which is likely not possible.

That this technical design isn’t possible doesn’t necessarily mean that the actual business requirement can be implemented. If you want, create a new thread and explain the business requirement there.