Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Contract class in report has null reference

(1) ShareShare
ReportReport
Posted on by 167
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 167 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 6,500 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 7,264 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 167 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 7,264 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

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,661 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans