Default Pricelist Opportunity
-
10 Mayıs 2012 Perşembe 09:58
The scenario is:
Users in different countries has their own portfolio of customers. Business rules say that those customers gets offers in their local currency - with few exceptions. We also have pricelists named by Currency (Country).
How do I add a Default pricelist when creating a new Opportunity? Will it be to read the value from currency on the opportunity and propose Pricelist = Currency by using javascript?
Tüm Yanıtlar
-
10 Mayıs 2012 Perşembe 10:08
you can write an Onload javascript for the opportunity form as below,
function Set(fieldName)
{
if(fieldName != null)
{
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = '00000000-0000-0000-0000-000000000000'; //GUID of the Pricelist Record
lookupValue[0].name = 'Price List'; //Name of the Record(Pricelist)
lookupValue[0].entityType = 'pricelevel';
Xrm.Page.getAttribute(fieldName).setValue(lookupValue);
}
}-Purush
- Yanıt Olarak Öneren Purush(MCTS) 10 Mayıs 2012 Perşembe 10:08
-
10 Mayıs 2012 Perşembe 10:11Moderatör
Hi,
you can do that you can read currency name from currency field and can pass currency name to one function, which will fetch pricelist based on the name passed.
I have written function to fetch pricelist based on it's name, you need to modify this function accordingly
refer :http://mahenderpal.wordpress.com/2011/06/28/set-default-price-list-in-ms-crm-2011-using-java-script/
let's us know if you are having any issue.
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Düzenleyen Mahender PalMVP, Moderator 10 Mayıs 2012 Perşembe 10:12
- Yanıt Olarak Öneren Mahender PalMVP, Moderator 10 Mayıs 2012 Perşembe 10:12
-
10 Mayıs 2012 Perşembe 12:22
after read currency name from currecy field you can use this function
function frmOnLoad() {
// If form Type = Create
if (Xrm.Page.ui.getFormType() == 1) {
// 1st Paramter is Price List Name, 2nd Paramter is Price List GUID
SetDefaultPriceList("test", "{9560968A-547A-E111-AAA0-00505683000F}");
}
}
function SetDefaultPriceList(prmPriceListName, prmPriceListId) {
//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem = new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = prmPriceListId;
lookupItem.typename = "pricelevel";
lookupItem.name = prmPriceListName;
// Add the object to the array.
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("pricelevelid").setValue(lookupData);
Xrm.Page.data.entity.attributes.get("pricelevelid").setSubmitMode("always");
}Crm Software Specialist
-
14 Mayıs 2012 Pazartesi 09:42
Everything looks fine when I use this code. The correct pricelist is defaulted (at least it look like it on hte screen), but when I Save the recI'm told that:
Record is unavailable
The requested record was not found or you do not hav suficient permission to view it.
Log File::
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: PriceLevel With Id = f7681105-17c3-e011-80ea-1cc1de0875ed Does Not ExistDetail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147220969</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>PriceLevel With Id = f7681105-17c3-e011-80ea-1cc1de0875ed Does Not Exist</Message>
<Timestamp>2012-05-14T08:35:03.3376077Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>Troubleshooting:
I've tried to google for information without finding any help. When I press the lookup button for Price List I can manually select the Pricelist. Then it's OK.
Reason/Solution?
Since I've no ideas about what's wrong suggestions would be much welcomed!
Hans Inge
-
14 Mayıs 2012 Pazartesi 11:01
Hi Hans,
Can you verify that you have the correct ID for the price list?
This error looks like there is no price list record with that ID.
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits