Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics RMS (Archived)

CurrentEntryKey Doesn't Seem to Work

(0) ShareShare
ReportReport
Posted on by 35

I'm just starting with trying to write a plug-in for RMS, and am having an issue.  In the c# code below, CurrentEntryKey always returns an empty string.  I want to know which entry is currently being added, but without that property working, I can't seem to do that.  Any ideas why that particular property doesn't work?

    [ComVisible( true )]
    [ClassInterface( ClassInterfaceType.None )]
    public class AddItemHook : IProcessSession
    {

        public bool Process( QSRules.SessionClass session )
        {
            //this statement always results in ""
            var currentItemKey = session.Transaction.get_CurrentEntryKey();
           
            return true;
        }
    }

Thanks

 -Nathan

*This post is locked for comments

  • Suggested answer
    dchang92606 Profile Picture
    dchang92606 95 on at
    RE: CurrentEntryKey Doesn't Seem to Work

    I know this is a really old thread, but I was working on this issue the other day, so I thought I would share my understanding of how this works...

    I think by the time RMS calls the AddItemHook, it has already processed the input and attempted to lookup the SKU and filled the Transaction and TransactionEntry objects and moved the cursor to the next line item (hence the current key is empty).  If you want to get the line item of the actual input, it's one line above.  Here's the code I use to get the actual line item that was entered ...

    ----- Begin Code -----

    int lineItemCount = this.RmsSession.Transaction.Entries.Count;

    TransactionEntry lineItem = this.RmsSession.Transaction.Entries[lineItemCount];

    string key = this.RmsSession.Transaction.get_CurrentEntryKey();

    int prevKeyIndex = 0;

    if (! String.IsNullOrEmpty(key))    // Key not empty

    {

       // Find the proper line item (one less than key match)

       bool found = false;

       for (int i=1; i<=lineItemCount; i++)

       {

           TransactionEntry li = this.RmsSession.Transaction.Entries[i];

           if (String.Compare(li.Key, key) == 0)

           {

               found = true;

               break;

           }

           prevKeyIndex = i;

       }

       if ((found) && (prevKeyIndex > 0))

          lineItem = this.RmsSession.Transaction.Entries[prevKeyIndex];

    }

    ----- End Code -----

    DC

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans