Customer Engagement & Dynamics CRM Forum

  • 1.  Creating a total lead time using C# and/or Javascript

    Posted 5 days ago
    Hi everyone! I hope you all are fine!

    I'm newbie in Dynamics CRM and C#/Javascript development, but I received a opportunity to work with it in my new job and I want to dedicate myself hard to learn all I can.

    I'm receiving some training for now and my first challenge is to calculate the lead time for a sales flow using C# or Javascript. I had some Ideas, for example, make a post save event as trigger to start the "chronometer" and, after that, the conclusion as final event to stop this counting time.

    However, every solution I think has a "BUT...". In this case, how Can I send the value to may main program in C#? Ajax? APIs?

    So, my question is: there is an way to make the same post event using C#? I wouldn't like to use buttons for the user press when to start the lead time.

    Could you give me some suggestions for this puzzle?

    Thanks a lot!


    ------------------------------
    Gilson Lima Junior
    Matera Systems
    ------------------------------


  • 2.  RE: Creating a total lead time using C# and/or Javascript

    Posted 4 days ago
    Hi Gilson,

    There are a ton of ways to do this. You first have to decide what counts as a "Total Lead Time" i.e. is it a button click or an event on the sales process? You can use the Business Process Flow start to finish time if that meets the requirement or as you said, a button the users can press to start the clock (not the best user journey - if bonuses are to be calculated on the lead time, you can be sure users will wait until a sale to click the button - even if not, they may want their stats to look good so will manipulate it). Usually best to do it on a status update or some other trigger.

    If it is the create of a lead record, you can run flows based on these things but having a timer ticking away is very poor practice. It is usually much better to mark a date/time field at the start, then at the end once the sale is made (or cancelled), you can calculate the time from then to now.

    To answer your question, a pre/during/post save event is what plugins were created for with C# and flows can be called directly from C#. There are loads of examples on this across the internet and in this forum. The same can be done using the webapi from JavaScript also, just remember the difference is that C# is run from the server side and JavaScript from the client (browser) side.

    In short, there are 'but's and different ways to do every question and solution on everything. It's just about getting what is best for your requirements.

    Hope that helps.

    ------------------------------
    Stephen Dear
    Artis Technology Limited
    GLASGOW SC
    ------------------------------



  • 3.  RE: Creating a total lead time using C# and/or Javascript

    Posted 4 days ago
    Many thanks for the explanation Stephen!

    Just to understand the scenario, there is a flow, where the first step is the "Potential Customer", after that it comes "Qualify", and more 2 steps until "Success Sale".
    My supervisor wants the total lead time (it means, since the potential customer was saved in this form, until the user click in "Gain sale" on the same menu where there is the save) showed in real time on the screen. This fact makes me think in a chronometer.

    Do you know the function or method in C# that start an event after save, just like the post save in Javascript?

    I didn't find it in the web, just how to save the form by command line.

    Thanks again!

    ------------------------------
    Gilson Lima Junior
    Matera Systems
    ------------------------------



  • 4.  RE: Creating a total lead time using C# and/or Javascript

    Posted 4 days ago
    Hi Gilson,

    When you create your plugin in the C# code, use the Plugin Registration Tool to register new plugin assembly. Within that assembly are steps which can be registered against events in the pipeline in Dynamics 365. For example, you could have a plugin which, responding to a status change event, takes a post image and uses the datetime to log somewhere. This can be registered against the Pre-validation, Pre-operation or Post-operation stage of execution. It can be run syncronously (tends to be bad practice but gives more certainty in the outcome) or Asynchronously. These can then be given different parameters of the event to provide a pre, post or both images - depending on the stage in the pipeline, those images mean different things but all documented. Review the SDK stuff and most is in there but needs a bit of lateral thinking to relate it to what you are trying to do...
    Plugin Registration Tool

    Hope that helps.

    Thanks,

    ------------------------------
    Stephen Dear
    Artis Technology Limited
    GLASGOW SC
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role