Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Contract class in repo...
Finance forum
Answered

Contract class in report has null reference

Posted on by 157
Hi Friends,
 

The report gets the following DataContract (PSAProjInvoiceContract) where it expects the data contract to be PMIPPSAProjInvoiceContract and it errors out.

This error is triggered when we preview invoices with retention release item i.e when we give retention percentage during posting of invoice.This is place where it happens.

Project Management and Accounting > Project Invoices > Project invoices> Filter for Proj Contract ID->then click on > Invoice> Go to View > Copy or Original >

The below image shows the place in code where the contract buffer is null.Also i have attached the call stack where custom code is used.I checked the custom code and

could not find any info.Can you please help me on where to get started to find the fix for this problem.Thank you.

 

The custom contract object has null reference.

  • Verified answer
    BADRI NARAYANAN G Profile Picture
    BADRI NARAYANAN G 157 on at
    Contract class in report has null reference
    Hi Friends,Thanks for your response.

    Actually the controller class RdpContract method was initialised with a different contract class and the code was trying to refer to a standard report contract class due to which the "object reference was null" error was triggered.We checked for the condition if the contract object was null or not.By doing this the problem was solved.
     
    Thank you
    Badri
  • Waed Ayyad Profile Picture
    Waed Ayyad 5,197 Super User 2024 Season 2 on at
    Contract class in report has null reference
    Hi,

    Is your issue resolved?  If yes, mark the answers that helped you as verified.

    Thanks
    Waed Ayyad
  • Layan Jwei Profile Picture
    Layan Jwei 6,886 Super User 2024 Season 2 on at
    Contract class in report has null reference
    Hi Badri,
     
    As I mentioned before we need to see your code.
    You said you duplicated the contract class but where did u define it in the RDP class?
     
    In the RDP class there is an attribute to define the contract class:
    [SRSReportParameterAttribute(classStr(ContractClass)]
     
    So if your contract is not defined in the RDP then it will be empty 
     
    Why did you duplicate the contract instead of adding new fields using extension..you don't want the original parameters to appear?
  • BADRI NARAYANAN G Profile Picture
    BADRI NARAYANAN G 157 on at
    Contract class in report has null reference
    Hi Layan , thanks for your response.

    Actually I duplicated the standard report contract class named PSAProjInvoiceContract and I have named the custom report contract class as  PMIPPSAProjInvoiceContract.It has two extract parameters added.

    The new controller class named PMIPPSAProjAndContractInvoiceController extends the standard controller class PSAProjAndContractInvoiceController.

    As stated above in the preRunModifyContract() method the contract class buffer is not being fetched it is returning null reference.

    Please let me know if there is any solution.Thank you.
  • Layan Jwei Profile Picture
    Layan Jwei 6,886 Super User 2024 Season 2 on at
    Contract class in report has null reference
    Hi Badri,

    I'm not getting what is your question exactly. If the custom contract is null, it makes sense that you get an object reference error, that's why you need to do defensive coding by checking if(customContract) before using it.

    Is your question why customContract is empty in the first place? we need to see your whole code what did u do exactly?

    does customContract extends the original class? show us the code you changed/added for contract, controller and RDP please

    Thanks,
    Layan Jweihan

    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans