Options

Error consuming Codeunit

sbillysbilly Member Posts: 231
edited 2011-05-11 in NAV Three Tier
Hi all;
I am exposing a codeunit with a function that i want to use inside my published page. Till here everything is allright,
but when I try to consume this codeunit I have this error : Parameter devis in method LancerDevis in service DevisVC is null!

Comments

  • Options
    MattKeyesMattKeyes Member Posts: 41
    Sounds like you are passing a null parameter. If you can post the code you are using to call the webservice, that would be helpful.
  • Options
    sbillysbilly Member Posts: 231
    MattKeyes wrote:
    Sounds like you are passing a null parameter. If you can post the code you are using to call the webservice, that would be helpful.
    Thanks for replay
    public void Button1_Click(object sender, EventArgs e)
            {
                
                          
                // Creation de l'en-tête Devis
                var Nouv_Dev = new DevisVC();
                Dev_srv.Create(ref Nouv_Dev);
                Nouv_Dev.Délai_de_validité = int.Parse(TB_DVal.Text);
                TB_No.Text = Nouv_Dev.No;
                TB_DatDev.Text = Nouv_Dev.Document_Date.ToShortDateString();
                //TB_Statut.Text = Nouv_Dev.Status.ToString();
                CB_VC.Checked = Nouv_Dev.Vente_à_Credit;
               // Creation ligne Devis
                Nouv_Dev.SalesLines = new Sales_Quote_Line[6];
                for (int i = 0; i < 6; i++)
                {
                    Nouv_Dev.SalesLines[i] = new Sales_Quote_Line();
                }
    }
    private void Button2_Click(object sender, EventArgs e)
            {
               Dev_srv.UseDefaultCredentials = true;
               Dev_srv.LancerDevis(Nouv_Dev.Key);
               Dev_srv.Update(ref Nouv_Dev);
            }
    

    After the creation of the quote with Button1, I want to release it by clicking Button2
  • Options
    MattKeyesMattKeyes Member Posts: 41
    You might try this:
    private void Button2_Click(object sender, EventArgs e)
            {
               if(Nouv_Dev != null && Nouv_Dev.Key != null)
               {
                        Dev_srv.UseDefaultCredentials = true;
                        Dev_srv.LancerDevis(Nouv_Dev.Key);
                        Dev_srv.Update(ref Nouv_Dev);
               }
            }
    

    From my understanding, it is likely you are doing this from an ASP.NET application, and all of the objects you are relying on may not be in a consistent state.
  • Options
    kinekine Member Posts: 12,562
    I think you have two variables with name Nouv_Dev. One defined in the Button1_Click into which you are reading the data, and one "global" which you are using in the Button2_Click, which is not initialized...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    sbillysbilly Member Posts: 231
    Hi all,
    I resolved it .
    All what i have to do is to re-read the quote.
    protected void Button2_Click(object sender, EventArgs e)
            {
    
                Nouv_Dev = Dev_srv.Read(TB_No.Text);
                Dev_srv.LancerDevis(Nouv_Dev.Key);
                
                                
            }
    
    thanks for all.
Sign In or Register to comment.