Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Clear all ranges on form Init

(0) ShareShare
ReportReport
Posted on by 100

Hello All,

Invent Aging Storage report is running on Create transaction ID for reference.

Now i am inserting some records in process method of InventAgingStorageService.

But the CreatedTransactionID created for these inserted records is different, hence when I will open the form for seeing the records by clicking on View details , i will not be getting the records I had inserted as It has a new transaction ID generated.

Base is using the following Query on init method :-

InventAgingTmp_ds.query().dataSourceTable(tableNum(InventAgingTmp))
.addRange(fieldNum(InventAgingTmp, CreatedTransactionId))
.value(queryValue(inventAgingStorage.TransactionId));

Now i had used my query to remove this range and tried to apply my own range to filter records which is :-

InventAgingTmp_ds.query().dataSourceTable(tableNum(InventAgingTmp)).clearRanges(); // cleared all ranges here

//Applied my ranges
query = InventAgingTmp_ds.query();
InventAgingTmp_ds.query().dataSourceTable(tableNum(InventAgingTmp))
 .addRange(fieldNum(InventAgingTmp, CustomTransactionId))
.value(queryValue(inventAgingStorage.TransactionId));

But the Output is following query:-

SELECT FIRSTFAST FORUPDATE * FROM InventAgingTmp(InventAgingTmp) WHERE ((CustomTransactionId = 5678296487)) AND InventAgingStorage.TransactionId=InventAgingTmp.createdTransactionId}

problem is because of this relation InventAgingStorage.TransactionId=InventAgingTmp.createdTransactionId which is defined on InventAgingStorage , i am unable to filter records , How can I remove this relation after AND , Please help me regarding this ??

*This post is locked for comments

  • mark wilson Profile Picture
    100 on at
    RE: Clear all ranges on form Init

    Thanks Sumit for your responce , I got your solution , This is also perfect .

  • mark wilson Profile Picture
    100 on at
    RE: Clear all ranges on form Init

    Thanks Martin , clearing dynalinks has solved my issue , Thank you so much.

  • Verified answer
    Sumit Loya Profile Picture
    2,230 on at
    RE: Clear all ranges on form Init

    Hi Mark,

    As Martin has beautifully explained the Dynalink concept, you can clear dynalinks in Init.

    Apart from this, I have couple of queries more. Are you updating the CustomTransactionId for standard lines as well that are created by framework apart from the custom lines that you create?

    If not, then the standard lines will be hidden if you just add link for CustomTransactionId.

    I would suggest, if you are not updating Custom field for standard lines as well, you add ranges for both the fields, CustomtransactionId and standard CreatedTransactionId.

    Also remember instead of adding AND condition, it should be OR condition. The underlying query should be something like this:

    SELECT FIRSTFAST FORUPDATE * FROM InventAgingTmp(InventAgingTmp) 
    WHERE ((CustomTransactionId = 5678296487)
        OR 
        (InventAgingTmp.createdTransactionId = 5678296487))

  • Martin Dráb Profile Picture
    234,035 Most Valuable Professional on at
    RE: Clear all ranges on form Init

    I don't know your particular case, but dynalinks are created automatically in a few situations. They're indeed based on table relations.

    One such a situation is when two form data sources are are linked (not joined), e.g. with a delayed link. You can see an example in sales orders. When you select a sales order header, the data source with lines is automatically filtered to show just lines for the selected header. That's caused by the dynalink.

    Another case is when you open a form from another, e.g. you go to customers and open Bank accounts. You'll see just accounts related to the selected customer, because a dynalink has been added automatically.

    It's also possible to add dynalinks from code, but it's not common. Almost all dynalinks are created automatically.

  • mark wilson Profile Picture
    100 on at
    RE: Clear all ranges on form Init

    Hello Champ @martin,

    I have one question , From where does this dynalink came , does it came from table relation ??

    And one more that , why do I need to replace with qbds (just asking for knowledge). ?

  • Verified answer
    Martin Dráb Profile Picture
    234,035 Most Valuable Professional on at
    RE: Clear all ranges on form Init

    It's a dynalink, not a range, therefore you need clearDynalinks() method instead of clearRanges().

    By the way, you can replace InventAgingTmp_ds.query().dataSourceTable(tableNum(InventAgingTmp)) with mere inventAgingTmp_ds.queryBuildDataSource() (and if you do it in datasource's init(), you can use simply this.queryBuildDataSource()).

  • mark wilson Profile Picture
    100 on at
    RE: Clear all ranges on form Init

    Hi Sumit ,

    But Multiple records are in InventAgingTmp and the header table is InventAgingStorage ,

    InventAgingStorage has one record in reference with InventAgingTmp(it has all records) with TransactionID , this table already has current transaction ID , If i will update this , then my inserted records will be visible , i need to see both my inserted records as well as standard inserted records.

    And while creating records i cannot do this inventAgingtmp.CreatedTransactionId = this.parmCreatedTransactionId() as CreatedTransactionID is system field and read only.

  • Suggested answer
    Sumit Loya Profile Picture
    2,230 on at
    RE: Clear all ranges on form Init

    Hi Mark,

    Instead of clearing range, you can try following line while you are creating your own record:

    inventAgingStorage.TransactionId = this.parmCreatedTransactionId();

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans