tags:

views:

500

answers:

2

Hi!

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?

A: 

Sure.

  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.

Kevin Swiber
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;}
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
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, 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
A: 

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; }