Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Trying to retrieve SalesLine.SalesId

Posted on by 15

Hello,

I would like to retrieve the current salesLine.SalesId in order to use it in the code of a configurator. Is it possible ? I didn't find a way to directly have it.

For example : if i'm using the configurator in the SalesLine with the SalesId : c067991, i would like to attribute that SalesId to a variable declare in the code of my configurator.

Thank you in advance

  • mickmiles Profile Picture
    mickmiles 10 on at
    RE: Trying to retrieve SalesLine.SalesId

    The best tactic for generating high-quality leads is to develop your own personal social media pages. Facebook, Twitter, and YouTube are all excellent avenues to use if you want to attract high-quality leads Belkins' outbound lead generation services. Social media allows you to develop relationships with people that you wouldn't normally have access to. People can be your best friends when you work hard to make them aware of your business. You will also have the opportunity to share information about your products with a wide audience.

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Trying to retrieve SalesLine.SalesId

    There is no PBAExecute class in my system.

    You didn't mention how (and if) you analyzed the data and the behavior of the class, so let me give you some ideas about what you should do.

    A useful technique is running the code in debugger and checking the data available in the class. You may spot a SalesLine or something like that straight away.

    If not, focus on how the class is instantiated and what data is passed to it. Pay special attention to the SalesLine data source and Args objects. Note that the debugger shows you the stack of method calls leading to calls of the class - it's instantiated somewhere in the previous calls.

  • AymericKer Profile Picture
    AymericKer 15 on at
    RE: Trying to retrieve SalesLine.SalesId

    The class does create the new item after the configuration. So I thought of putting my code in the run() method so everytime it creates a new item i can have the salesLine.salesId.

    But i don't know how to get it...

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Trying to retrieve SalesLine.SalesId

    No, creating a new empty variable wouldn't be useful in any way. What to you need to do is checking what the class does and thinking about where you should place your logic and how you'll get the data you need.

  • AymericKer Profile Picture
    AymericKer 15 on at
    RE: Trying to retrieve SalesLine.SalesId

    I think i identified the class, it's PBAExecute but SourceLine variable doesn't exist on it. Should i create it or i can call sourceLine variable from that class ?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Trying to retrieve SalesLine.SalesId

    There are several ways how to find this information. For example, if it's opened by a button from a form, look at the button. It typically points to menu item which opens either a class or a form. Or it may be a simple button with code in clicked().

    Or if the logic opens a form, right-click the form and check its name. Then you can put a breakpoint to the form and review the full call stack in the debugger.

    Or if you know about other logic executed by the process (e.g. that it creates a record in a table), you can put breakpoint there.

    It's impossible to say whether the class has sourceLine variable unless we identify the class.

  • AymericKer Profile Picture
    AymericKer 15 on at
    RE: Trying to retrieve SalesLine.SalesId

    I want it to run when i start the configuration of the product so then i can have the value of sourceLine.SalesId during the configuration.

    I tried with the code in runMain() and the salesId is show on the info so it seems to work. But I just identified a problem : the PCExecuteVariantConfiguration class corresponds to product configuration models and not to product models. How can i know which classes is used by product models ? And if it's still possible to use sourceLine ?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Trying to retrieve SalesLine.SalesId

    Where you should put your logic depends on what you want to achieve. Think about when you want to run your logic and then review the code of the class. Maybe saveConfiguration() would meet your needs - it's called from runMain() is parmIsClosedOK() returns true.

    The purpose of the code above is casting sourceLine variable to SalesLine type, so you can access the SalesId field.

    The type of sourceLine variable is Common, which is a parent type for all tables. It doesn't have SalesId field, therefore you can't write something like sourceLine.SalesId. But if you cast it to SalesLine type, you can access SalesId, as demonstrated by info(salesLine.SalesId).

  • AymericKer Profile Picture
    AymericKer 15 on at
    RE: Trying to retrieve SalesLine.SalesId

    No i still think i can't use SalesLine, but didn't understand what your suggestion was. But i still don't get where i should put this code in the class PCExecuteVariantConfiguration :

    SalesLine salesLine = sourceLine as SalesLine;
    if (salesLine)
    {
    	info(salesLine.SalesId);
    }

    If I understand correctly, with this code we assign the value of sourceLine which inherits its value from SalesLine to the object salesLine ? So this shoud be write in my product model ?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Trying to retrieve SalesLine.SalesId

    sourceLine is a table buffer containing (in your case) a SalesLine record. It doesn't have any reference to PCExecuteVariantConfiguration class. It's the other way - sourceLine is a member of PCExecuteVariantConfiguration class. Therefore if you have a PCExecuteVariantConfiguration object, you have sourceLine, but if you just have a reference to a table buffer, it doesn't give you any reference to PCExecuteVariantConfiguration class. You also said that you can't work with SalesLine alone, because - I quote - "informations that i'm sending to the table are not related to the salesLine and are only related to choices of users when using the product model.". Because you rejected this idea, I wasn't talking about it since my second reply. Do you have a reason for returning to this point in the discussion?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans