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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to assign null value to string parameter using contract class

(1) ShareShare
ReportReport
Posted on by 3,045
Hi All,
 
I have created contract class which consist string parm method. I am using this contract class for JSON searilization and then passing data to third party application. As per the requirement all the blank string values should be assign null value and json output should be like:
 
{
/name/: null
 
I have tried passing null value to method in the case output is coming like as below:
{
/name/:/ /
}
 
Please guide how I can achieve this. Thanks. 
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    Try the below code:
    static void Job5(Args _args) 
    { 
        System.String nullStr; 
        nullStr = CLRInterop::Null("System.String"); 
        print CLRInterop::isInitialized(nullStr); 
        print CLRInterop::isNull(nullStr); 
    }
    Based on this document:
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Pooja Karki Profile Picture
    3,045 on at
    I have tried below line and it is returning blank output.
     
    CLRInterop::Null("System.String");
  • Suggested answer
    Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi,
     
    Did you try to set the string with "null", give it a try and tell us the result.
     
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
  • Pooja Karki Profile Picture
    3,045 on at
    Yes, I have tried passing value like:
     
    classname.methodname(CLRInterop::Null("Null"));
     
    in this case it is returning blank value.
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    If your methodname() method accepts str type and the backing variable is str too, it can't store null values. I don't know whether changing it to System.String will work, but it definitely can't work with str.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans