Tech Support > Microsoft Windows > Windows CRM > Opportunity Product Default Unit - Problem
Opportunity Product Default Unit - Problem
Posted by James Zhang on August 16th, 2006


Does it possible to load and fill the default Unit of opportunity product
when used select a new product in Product lookup fields? So user does not
have to select the Unit of the selected product every time even there is
only one unit related with the product???

Do I need use querybyattribute / querybyexpress to retrieve the Unit from
CRM database?
Or it is not supported by CRM?

I used following but not work, please help!!!
============================================
var lookupitem=new Array;
lookupItem=crmForm.all.uomid.DataValue;
//there is no value or undefined for the uomid.DataValue
If (lookupItem !=null)
If (lookupItem[0] !=null)
CrmForm.all.uomid.DataValue[0].name=lookupItem[0].name;
============================================

Posted by ungaio on August 22nd, 2006


I can get you only part way there, as I don't know how to query the DB to get
the data that you need (GUID, TypeCode and Name) from UoMBase

If you can figure out how to query these from the database, I would love to
know.



I just did this today at OpportunityProduct Form for the OnLoad event. We
only have one unit, and typically our quantity is 1.


//
// This sets the default values for Quantity and Unit of Measure upon a new
form
//
// Quantity = 1, UOM = Each
//
//
var CRM_FORM_TYPE_CREATE = "1";
var lookupItem = new Array();
var iUnit = "Each";
var iQuantity = 1;

if (crmForm.FormType==CRM_FORM_TYPE_CREATE)
{
// set quantity to a default of 1 for new opportunity products
crmForm.all.quantity.DataValue = iQuantity

// Set: GUID of unit "Each", object type code and the text name "Each".
lookupItem[0] = new LookupControlItem
("{9D538BAC-1C26-DB11-9BF0-000C291548C3}", 1055, "Each");

// Set the form control value to the lookupItem just created.
crmForm.all.uomid.DataValue = lookupItem ;
}


regards,

Steveh.

"James Zhang" wrote:

Posted by Manisha Powar \(MSFT\) on August 25th, 2006


* To get the unit GUID, click on the unit and hit Ctrl+N
* to get the object type code, login to the physical CRM server and use
http://localhost/sdk/list.aspx to see the entity definition. Select the
entity definition of uom and the object type code should be visible in the
top row
--
Manisha Powar (Madhusudanan)
Program Manager
Microsoft Dynamics - CRM

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2005 Microsoft Corporation. All rights
reserved.
"ungaio" <ungaio@discussions.microsoft.com> wrote in message
news:8BCC9CE8-F9B6-4629-81B8-3CD1FA3B7064@microsoft.com...



Similar Posts