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. 
  • Martin Dráb Profile Picture
    233,029 Most Valuable Professional on at
    How to assign null value to string parameter using contract class
    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.
  • Pooja Karki Profile Picture
    3,045 on at
    How to assign null value to string parameter using contract class
    Yes, I have tried passing value like:
     
    classname.methodname(CLRInterop::Null("Null"));
     
    in this case it is returning blank value.
  • Suggested answer
    Waed Ayyad Profile Picture
    8,335 Super User 2025 Season 1 on at
    How to assign null value to string parameter using contract class
    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
    How to assign null value to string parameter using contract class
    I have tried below line and it is returning blank output.
     
    CLRInterop::Null("System.String");
  • Suggested answer
    Waed Ayyad Profile Picture
    8,335 Super User 2025 Season 1 on at
    How to assign null value to string parameter using contract class
    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,349 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,029 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans