Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Converting a recid to formdatasource format

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I have a customised class in which I want to call a standard class method example 

the class is WhsUnshipLoadLine and the method is unship().

now this method takes formdatasoucre as parameter but since I am using it in custom class and this method is not being called from a form, I want to somehow pass recid as argument in this parameter when calling this method in my class. Is it possible to convert a recid value to formdatasource format and then passing it in the method parameter? Please help.

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Converting a recid to formdatasource format

    As I said - look at the method, borrow what you need and ignore isn't relevant or useful in your scenario. If you the logic in isunpickingfullloadline(), then use it.

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    Thanks you Martin, but there are few conditions on WHSUnshipLoadLineForm class as well which I think need to be checked before using Whshnship class for this process.

    For example - whsunshiploadlineform.isunpickingfullloadline() method.

    Please correct me if am wrong?

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Converting a recid to formdatasource format

    1. I already addressed this above. Yes, you need a custom method, but you shouldn't implement something similat to WhsUnship class. You should use this class in your method.

    2. Yes, both entities and classes can have more than one method.

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    Actually my  scenario is… I have created a custom table XYZWhsUnshipLoadLineTable and a custom data entity ‘XYZWhsUnshipLoadLineEntity’ for this table. A  third party is filling the data in this custom table through OData and now we need to create a OData action on this entity so that they can call this action method and through that method the we could perform the unshipping of quantity automatically.

    It’s like once they have filled the data into the table we have to call the whsunshiploadlineform.unship() method and reduce the quantity for the laod lines which they have sent into the table.

    Now my question is -

    1. Since the method takes formdatasource as the argument then I will I have to write my own logic similar to whsunship class to reduce the quantity right?

    2. Can I create multiple methods inside my entity class to perform this activity.

    Please see screenshot below

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    0172.image.jpg

    Example-

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Converting a recid to formdatasource format

    Please see my suggestion above. If you don't like it, please explain what problem you have with it.

    Repearing "Any suggestions please help" is useless, because it provides no information on the topic.

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    Any suggestions please help

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    Any suggestions please help

  • Karuna Dogra Profile Picture
    Karuna Dogra on at
    RE: Converting a recid to formdatasource format

    Thank you Martin,

    Actually I am creating a OData action method in which I want to call this method and automatically perform the unship method functionality. Shoul I write a replicate of that method in my custom class to perform that functionality without automatically without form interaction.

    Please help.

  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    RE: Converting a recid to formdatasource format

    What RecId do you have? If it's a RecId of WHSTmpLoadLineInventory table, it's useless without a reference to a temporary data set. WHSTmpLoadLineInventory is a temporary table is has no data in database at all.

    Regarding the method, you can see thayt it isn't good for your purpose, because it requires a form data source, while you don't have any. And you can't create a form data source without a form.

    I would look into unship() method and borrow the logic I need. You'll see that most work is done by WHSUnShip class.

    Note that other parts of the method are not relevent in your case. For example, the logic getting records selected in a grid makes no sense when you don't have a form. Also, there is no point in running a while select against multiple records if you have just a single one (I'm not sure by that, it's just an assumption).

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans