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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Remove { } from id javascript

(0) ShareShare
ReportReport
Posted on by 600

Hi

I am new to javascript and am trying to create a dynamics url to open a dialog box.

To get the object id for a record I use the selectedItem.id 

This gives me a result in this format {406CE8D0-8757-E811-A821-005056A14CB5}

To use this in a URL I need to get rid of the { and }. How is this possible?

Thanks for help!

My code:

function run(selectedItems)
{
var selectedItem = selectedItems[0];
var url = Xrm.Page.context.getClientUrl()+ "/cs/dialog/rundialog.aspx?DialogId=%7b2DED86E4-AAA5-4317-B07C-E3938A170002%7d&EntityName=incident&ObjectId=%7b"+selectedItem.Id + "%7d";
// Here you can use the information below to open a new window or whatever!
alert(selectedItem.Id);
alert(url);
window.open(url, "", "height=700, width=550");

}

*This post is locked for comments

I have the same question (0)
  • martingr Profile Picture
    600 on at
    RE: Remove { } from id javascript

    Thank you all for correct answers!!

  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Remove { } from id javascript

    Hi Martin,

    This is what you should do :

    var newid = selectedItem[0].id.slice(1, -1);

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Remove { } from id javascript

    Hello , 

    Try with this -

            function run(selectedItems) {
                var selectedItem = selectedItems[0];
                var selId = selectedItem.Id;
                selId = selId.replace("{", "").replace("}", "");
                var url = Xrm.Page.context.getClientUrl() + "/cs/dialog/rundialog.aspx?DialogId=%7b2DED86E4-AAA5-4317-B07C-E3938A170002%7d&EntityName=incident&ObjectId=%7b" + selId + "%7d";
                // Here you can use the information below to open a new window or whatever!
                alert(selectedItem.Id);
                alert(url);
                window.open(url, "", "height=700, width=550");
    
            }


  • Suggested answer
    Shahbaaz Ansari Profile Picture
    6,211 on at
    RE: Remove { } from id javascript

    Hi,

    Please check below link,

    community.dynamics.com/.../242420

    Thanks,

    Shahbaaz

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Remove { } from id javascript

    Hi,

    pass the value into below function

    function convertGuid(str) {

       if (str) {

           str = str.replace(/[{}]/g, '');

           str = str.toUpperCase();

       }

       return 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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans