Skip to main content

Notifications

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

How to post code in dynamics community in a proper format

(0) ShareShare
ReportReport
Posted on by 1,550
Hi,
 
When i post code in dynamics community it appears in a wrong format. How to make it appear properly.
 
For example i posted this question, before clicking post it was in a good format then it appeared in one line like this link:
 
  • junior AX Profile Picture
    junior AX 1,550 on at
    How to post code in dynamics community in a proper format
    Hi Martin,

    I had to post something to see if it's working.

    I'm not sure why the question appears wrongly. Maybe it only works in answers
  • Martin Dráb Profile Picture
    Martin Dráb 230,934 Most Valuable Professional on at
    How to post code in dynamics community in a proper format
    I'm sorry, but we can't review your steps regarding "This one is not working", because you didn't mention them. If you need our help, please provide this information.
     
    Otherwise I'm assuming that you now know how to use Insert Code Snippet and this thread can be closed.
  • junior AX Profile Picture
    junior AX 1,550 on at
    How to post code in dynamics community in a proper format
    [DataContractAttribute] 
    class Contract1
    {   str callerName;
        str packedQuery;
        str ContainerStr;
        
        public str parmCallerName(str _callerName = callerName) 
        {   callerName = _callerName;
            return callerName;
        } 
        
        public str containerStr(str _containerStr = containerStr)
        { 
            containerStr = _containerStr;
            return containerStr;
        } 
        
        [ DataMemberAttribute, 
        AifQueryTypeAttribute('_packedQuery', queryStr(Query1))] 
        
        public str parmQuery(str _packedQuery = packedQuery)
        {   
            packedQuery = _packedQuery;
            return packedQuery;
        } 
    
        public void setQuery(Query _query)
        { 
            packedQuery = SysOperationHelper :: base64Encode(_query.pack());
        } 
        
        public Query getQuery() 
        { 
            return new Query(SysOperationHelper :: base64Decode(packedQuery));
        }
        
    }
        
    This one is not working

    ​​​​​​​
    [DataContractAttribute] 
    class Contract1
    {   str callerName;
        str packedQuery;
        str ContainerStr;
        
        public str parmCallerName(str _callerName = callerName) 
        {   callerName = _callerName;
            return callerName;
        } 
        
        public str containerStr(str _containerStr = containerStr)
        { 
            containerStr = _containerStr;
            return containerStr;
        } 
        
        [ DataMemberAttribute, 
        AifQueryTypeAttribute('_packedQuery', queryStr(Query1))] 
        
        public str parmQuery(str _packedQuery = packedQuery)
        {   
            packedQuery = _packedQuery;
            return packedQuery;
        } 
        public void setQuery(Query _query)
        { 
            packedQuery = SysOperationHelper :: base64Encode(_query.pack());
        } 
        
        public Query getQuery() 
        { 
            return new Query(SysOperationHelper :: base64Decode(packedQuery));
        }
        
    }
        

  • junior AX Profile Picture
    junior AX 1,550 on at
    How to post code in dynamics community in a proper format
    I did this:

    ​[DataContractAttribute]
     class Contract1
    {
        str                                    callerName;
        
        public str parmCallerName(str _callerName = callerName)
        {
            callerName = _callerName;
            return callerName;
        }
    }
    
    ​
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,934 Most Valuable Professional on at
    How to post code in dynamics community in a proper format
    What I do is pressing Insert Code Snippet (the second button from the right in the toolbar; it doesn't seem to have any icon) and simply putting code there.
    try
    {
        info("abc");
    }
    Edit: Mohit was faster. But the difference is that I don't see the icon (the button works for me too).
  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    How to post code in dynamics community in a proper format
    Its working, so you can use 'Insert Code Snippet' button.
  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    How to post code in dynamics community in a proper format
    public void insert()
    {
        super();
    
        HcmWorker::flushCurrentWorker();
    }  
    Note: Testing with above code if Insert Code Snippet button works correctly
     

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans