web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Suggested answer
    Sumit Loya Profile Picture
    2,230 on at

    Hi Mark,

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

    inventAgingStorage.TransactionId = this.parmCreatedTransactionId();

  • mark wilson Profile Picture
    100 on at

    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.

  • Verified answer
    Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    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

    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). ?

  • Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    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.

  • Verified answer
    Sumit Loya Profile Picture
    2,230 on at

    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))

  • mark wilson Profile Picture
    100 on at

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

  • mark wilson Profile Picture
    100 on at

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans