Take the 2-minute tour ×

I want to create a custom textfield in a serviceactivity. When the serviceactivity onloads I would like to have the serviceactivities GUID in that textfield. Does anyone have any idea how I can solve this?

share|improve this question
This is regarding MS CRM 4.0 –  Martin Jun 9 '09 at 12:07
@Martin: please update your question rather than adding more info to comments. Thanks. –  Mitch Wheat Jun 9 '09 at 12:09

1 Answer 1


  1. Create a new attribute (myguid) on the entity to hold the GUID.
  2. Go into the main form customization for that entity.
  3. Add the new myguid field to your form.
  4. On the form properties, alter the onLoad event.
  5. Use crmForm.ObjectId to get the GUID value.

Example: crmForm.all.myguid.DataValue = crmForm.ObjectId;

You might wanna check out the CRM 4.0 SDK.

share|improve this answer
Hi! Thanks for the answer. I have done what you´ve said andused the following code to get the GUID value...I an error that crmForm.all.myguid.Datavalue is null or not an onject. Can you see in my code what I´ve done wrong? var myguid = crmForm.ObjectId; if(crmForm.all.myguid.DataValue != null) { crmForm.all.myguid.DataValue = crmForm.ObjectId; } –  Martin Jun 10 '09 at 8:48
In this case, myguid should be an nvarchar Text attribute field. Make sure this attribute field is added to your form before running that code. –  Kevin Swiber Jun 10 '09 at 13:04
Thank you very much for your answer. I really appreciate it. I had the wrong attributename so I have fixed that... Now I don´t receive any more errormessage.. But still no value appear in my textfield. This is my code: var new_myguid = crmForm.ObjectId; if(crmForm.all.new_myguid.DataValue != null) { crmForm.all.new_myguid.DataValue = crmForm.ObjectId; } Can you see if the code works in your CRM? –  Martin Jun 11 '09 at 12:56
@Martin, Because crmForm.all.new_myguid.DataValue == null, your if condition is never being met. Just use the following code without all the extras: crmForm.all.new_myguid.DataValue = crmForm.ObjectId; –  Kevin Swiber Jun 11 '09 at 13:34

Your Answer

