web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

to pass the default value in init value of form

(1) ShareShare
ReportReport
Posted on by 1,836
hi,
everyone,
I have customise form in which there is grid i need to increment the sqeuence number in grid so i have use the init value method , but my saquence no is not getting incremented ,
can anyone please help me on this .the line number is appearing 0, i want it to increment , please guide me on this .
 
thanks,
Regards,
Dinesh
  • Dineshkarlekar Profile Picture
    1,836 on at
    below is my code on form ds
       public void initValue()
            {
    
                DTDMCHeaderLines   dTDMCHeaderLinesloc;
                Info(strFmt("InvoiceDate:%1,inventLocationId:%2",DTDMCHeaderLines_inventLocationId,DTDMCHeaderLines_InvoiceDate));
    
                if(DTDMCHeaderLines.InvoiceDate != dateNull() && DTDMCHeaderLines.inventLocationId != '')
                {
                    select firstonly Seqnum from dTDMCHeaderLinesloc
                    order by DTDMCHeaderLinesloc.Seqnum  desc
                    where dTDMCHeaderLinesloc.InvoiceDate == DTDMCHeaderLines.InvoiceDate
                    && dTDMCHeaderLinesloc.inventLocationId == DTDMCHeaderLines.inventLocationId;
            
                  DTDMCHeaderLines.Seqnum =  dTDMCHeaderLinesloc.Seqnum + 1 ;
                }
                super();
            }
     
  • Martin Dráb Profile Picture
    240,807 Most Valuable Professional on at
    Let me remind you again that you have the debugger at your disposal, which will tell you what's going on in your code. You must learn how to use it to be able to do your job. As you see, guessing what's wrong doesn't work for you and using this forum instead of the debugger is very inefficient.
     
    Please put the breakpoint at if condition, run your project or attach the debugger to the web server and add a line. Tell us whether you get into the body of the if statement. I don't think so - your code will run only if InvoiceDate and InventLocationId fields have values, but that's not the case of a newly created record.
     
    I think you should take the values from the header, not from the line. The header must already exist when you're creating lines for it, but not no line exists before you create the first one.
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi , 
    how can i fetch the header in this method , you are right i am not getting the value in if , can you please guide me on this .do i have write the code on invit value of header , or should i keep it on line .
     
    thanks,
    Regards,
    Dinesh
  • Dineshkarlekar Profile Picture
    1,836 on at
     i have , made some changes in code now try to debug it , let you know what i get.
      public void initValue()
            {
    
                DTDMCHeaderLines   dTDMCHeaderLinesloc;
                Info(strFmt("InvoiceDate:%1,inventLocationId:%2",DTDMCHeaderLines.InvoiceDate,DTDMCHeaderLines.inventLocationId));
    
                //get any datasource from the base form      
                DTDMCHeader             dTDMCHeaderloc                  = DTDMCHeader_ds.Cursor();
              
                if(dTDMCHeaderloc.InvoiceDate != dateNull() && dTDMCHeaderloc.inventLocationId != '')
                {
                    select firstonly Seqnum from dTDMCHeaderLinesloc
                    order by DTDMCHeaderLinesloc.Seqnum  desc
                    where dTDMCHeaderLinesloc.InvoiceDate == dTDMCHeaderloc.InvoiceDate
                    && dTDMCHeaderLinesloc.inventLocationId == dTDMCHeaderloc.inventLocationId;
            
                
                  DTDMCHeaderLines.Seqnum =  dTDMCHeaderLinesloc.Seqnum + 1 ;
                }
                super();
            }
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    thanks for reply ,
     
    I have made changes in code on form line datasource i have written this code .
      public void initValue()
            {
     
                DTDMCHeaderLines.InvoiceDate = DTDMCHeader.InvoiceDate;
                DTDMCHeaderLines.inventLocationId = DTDMCHeader.inventLocationId; 
                super();
            }
    and on table i have override this method which gets vaslue from form dsmethod .
     public void initValue()
        {
            super();
    
            DTDMCHeaderLines   dTDMCHeaderLines;
            //Info(strFmt("InvoiceDate:%1,inventLocationId:%2",this.inventLocationId,this.InvoiceDate));
    
            if(this.InvoiceDate != dateNull() && this.inventLocationId != '')
            {
                select firstonly Seqnum from dTDMCHeaderLines 
                    order by DTDMCHeaderLines.Seqnum  desc 
                    where dTDMCHeaderLines.InvoiceDate == this.InvoiceDate 
                    && dTDMCHeaderLines.inventLocationId == this.inventLocationId;
            
               // this.CustomerName    = CustTable::find(this.InvoiceAccount).name();
                this.Seqnum =  dTDMCHeaderLines.Seqnum + 1 ;
            }
    
        }
    the value get incremented on create button but when i click on save it trigger the error that cannot create record in dtdmcheaderlinestable the record already exist.
  • Martin Dráb Profile Picture
    240,807 Most Valuable Professional on at
    It seems that you're trying to save a record with values of a unique key that already exist.
  • Suggested answer
    Nisha Soni 2709 Profile Picture
    on at
    Create number sequenece and attach it with that field.
  • Verified answer
    Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    Thanks for reply invoice i was index filed thats why i was not getting the error on save i removed that now i am , now number are incrementing with code.
     
     
    thanks,
    Regards
    Dinesh
  • Waed Ayyad Profile Picture
    9,218 Super User 2026 Season 2 on at
    Hi,
     
    If your issue is resolved, mark the correct answer as verified answer.
     
    Thanks,
    Waed Ayyad

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 475 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 399 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 374

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans