locked
CRM 2011 Orders to Invoice, calling a web service RRS feed

  • Question

  • Hi All,

    Could someone please give me some advice? I am new to CRM as well as web programming.

    I created a ribbon button that displays when Orders grid is displayed and that is enabled when several orders are selected. Now I want to bundle the selected orders into a single invoice. Could someone advice me on how I could do this?

    I could write a complex JS that would perform this but I would rather avoid it if possible. In other words, I would rather call some kind of service from java script that would perform the operation for me.  

    Tuesday, November 8, 2011 3:01 AM

Answers

All replies

  • By default, it is not posible.  The order is attached to just one order.

    You can try to customize it by creating 1:N relationship with invoice and orders or create a custom invoice entity to fullfil your needs.

    I hope this helps.


    Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Tuesday, November 8, 2011 5:26 AM
    • Unproposed as answer by Kotena Tuesday, November 8, 2011 6:18 AM
    Tuesday, November 8, 2011 5:26 AM
  • Thank you for your reply Amreek, 

    the problem is not really in how to bundle orders to a single invoice but how to call a service that would perform some complex operation (e.g. it would look through the orders and then will create an invoice based on the selected orders).  For instance, I can perform almost any complex operation such as this one through plug-ins, but the use of a plug-in is not suitable at this situation.

    I believe that it is possible to write a very complex code in js that would do it but I want to avoid it. I would rather have some custom aspx that performs the operation on the server while displaying the progress bar to the end user.

    I am totally new to all this so please forgive me if I do not explain everything clear.

    The main issue here is

    How to use the logged-in user credentials to perform this operation. Our organization is running CRM on premise with AD authentication.

    If anyone have an example it would be much appreciated. 

    Thank you


    Kotena
    Tuesday, November 8, 2011 6:18 AM
  • You can create a silverlight web resource and call that from the ribbon button. The selected orders guid would be passed to the silverlight resource.

    The silverlight resource can then read the orders and create a single invoice using the lines. When you create a silverlight resource you need to use CRM ODATA. When used within CRM the context and credentials is auto passed.

    You can check the samples in the SDK.

    HTH

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Sam - Inogic Tuesday, November 8, 2011 9:05 AM
    • Unproposed as answer by Kotena Thursday, November 10, 2011 1:45 AM
    Tuesday, November 8, 2011 9:05 AM
  • Hi, I used the code below to return the transaction currency which I use through ajax call on the entity form. CrmConnection should handle every type of authentication, you should just combine parameters (in this example the target is IFD deployment). You can use CrmSvcUtil to generate strong type class for your organization entities. Everything is well documented in SDK.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Client;
    using Microsoft.Xrm.Client;
    using Microsoft.Xrm.Client.Services;
    using Microsoft.Crm.Sdk.Messages;
    public partial class GetRate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override void Render(HtmlTextWriter writer)
        {
            Response.Clear();
            Response.ContentType = "text/xml";
            string clientResponse = "";

            CrmConnection conn = CrmConnection.Parse("Url=https://orgname.dynamicscrmhosting.com; Username=yourUsername; Password=password;");
            using (OrganizationService service = new OrganizationService(conn))
            {
                OrganizationServiceContext srvContext = new OrganizationServiceContext(service);


                IEnumerable<decimal?> exchRate = from t in srvContext.CreateQuery<TransactionCurrency>()
                                where t.ISOCurrencyCode.Equals("EUR")
                                select t.ExchangeRate;
               
                if (exchRate.Count() > 0)
                    clientResponse = exchRate.First().Value.ToString();
                else
                    clientResponse = "error";

            }

            Response.Write(clientResponse);
            Response.End();
        }
    }


    Zarko
    Tuesday, November 8, 2011 9:06 AM
  • Hi 

    you need to use default credential to run the custom code as logged in user

    here is step by step tutorial to create a web app using default credential.

    Create a custom button, get all the selected Ids and call your custompage passing these guids as parameter.

    I hope this helps.

     


    Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Tuesday, November 8, 2011 11:58 AM
    • Unproposed as answer by Kotena Thursday, November 10, 2011 1:45 AM
    • Edited by Amreek Singh Thursday, November 10, 2011 1:49 AM
    Tuesday, November 8, 2011 11:58 AM
  • Guys,

    Thank you so much for your replies!

    Amreek, what you have said make sense...almost. First of all, you mentioned some step by step tutorial, but I do not see any link.

    Here is what I have resolved to do so far:

    1. Create an aspx page in a separate web site

    2. Store super user, login and password in Web.config of my aspx page

    3. Pass the user id when calling the page from java script, e.g. <location>/page.aspx?userid={<id>}

    4. On page load (or else)  connect to the CRM using stored super user credentials

    5. Set service.CallerID = userId, where userID is the user id passed as parameter, and service is OrganizationServiceProxy object. This will allow me to act on behalf of the calling user, even though I'm connecting using the super user credentials.

     

    Could you or anyone else tell me if this is reasonable solution?

     

    Thank you!

     


    Kotena
    Thursday, November 10, 2011 1:44 AM
  • You can do that for sure, or you can use default credential

    here is the missing link

    http://blogs.msdn.com/b/crminthefield/archive/2011/06/03/microsoft-dynamics-crm-2011-custom-contact-entry-website-using-early-bound-entity-classes.aspx

    I hope this helps.

    If this blog answer your question please mark it as answer/helpful

     


    Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Thursday, November 10, 2011 1:53 AM
    • Marked as answer by Kotena Thursday, November 10, 2011 2:33 AM
    Thursday, November 10, 2011 1:53 AM
  • Thank you Amreek and everyone else for your answers!
    Kotena
    Thursday, November 10, 2011 2:35 AM