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

Contract class in report has null reference

(1) ShareShare
ReportReport
Posted on by 220
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.

  • Layan Jwei Profile Picture
    8,331 Super User 2026 Season 2 on at
    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
  • BADRI NARAYANAN G Profile Picture
    220 on at
    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
    8,331 Super User 2026 Season 2 on at
    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?
  • Waed Ayyad Profile Picture
    9,218 Super User 2026 Season 2 on at
    Hi,

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

    Thanks
    Waed Ayyad
  • Verified answer
    BADRI NARAYANAN G Profile Picture
    220 on at
    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

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 555 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
CU10121822-0 Profile Picture

CU10121822-0 378

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans