顯示具有 CRM 標籤的文章。 顯示所有文章
顯示具有 CRM 標籤的文章。 顯示所有文章

2016年6月21日 星期二

CRM2011 Placeholder

CRM2011 Placeholder For IE 10 up




Javascript
function OnLoadForm(){

    document.getElementById("description").placeholder = "Description for opportunity";

    this.LoadCSS("/WebResources/style.css");

}




function LoadCSS(path) {

    var head = document.getElementsByTagName('head')[0];

    var link = document.createElement('link');

    link.rel = 'stylesheet';

    link.type = 'text/css';

    link.href = path;

    link.media = 'all';

    head.appendChild(link);

}


CSS
::-webkit-input-placeholder { /* Chrome/Opera/Safari */

  color: Gray;

}

::-moz-placeholder { /* Firefox 19+ */

  color: Gray;

}

:-ms-input-placeholder { /* IE 10+ */

  color: Gray;

}

:-moz-placeholder { /* Firefox 18- */

  color: Gray;

}

CRM2011 JavaScript Load up CSS file

CRM2011 JavaScript Load up CSS file



1.Attach the following code to the web resource






2.Add the function to the priority on-change and to form onload (Call the function in an existing onload)



function OnLoadForm(){

    this.LoadCSS("/WebResources/css_form_opportunity.css");

}



function LoadCSS(path) {

    var head = document.getElementsByTagName('head')[0];

    var link = document.createElement('link');

    link.rel = 'stylesheet';

    link.type = 'text/css';

    link.href = path;

    link.media = 'all';

    head.appendChild(link);

}




2016年6月13日 星期一

CRM2011 PluginRegistration Tool(Update Assembly)

CRM2011 PluginRegistration Tool(Update Assembly)



1.Select Assembly / Update



2. Select /Open DLL


3.Load Assembly / Select existing Assembly or new Assembly / Update Selected Plugins








CRM2011 PluginRegistration Tool(Register New Assembly)

CRM2011 PluginRegistration Tool(Register New Assembly)


1.Register / Register New Assembly




2.Browser/Open DLL 




3.Load Assembly/ Register Selected Plugins




CRM2011 Opportunity Alert Message on Close Won(Plugin)

CRM2011 Opportunity Alert Message on Close Won(Plugin)

PreWinOpportunity.cs

if (context.InputParameters.Contains("OpportunityClose") && context.InputParameters["OpportunityClose"] is Entity)

            {

                #region Throw Exception For Test

                //throw new InvalidPluginExecutionException("PreWinOpportunity - OpportunityCloseWon");

                #endregion



                var entity = (Entity)context.InputParameters["OpportunityClose"];



                if (entity.Attributes.Contains("opportunityid"))

                {

                    var opportunityId = ((EntityReference)entity.Attributes["opportunityid"]).Id;



                    var serviceFactory =

                     (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));



                    // Getting the service from the Organisation Service.

                    IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId);



                    Entity opportunity = crmService.Retrieve("opportunity", opportunityId, new ColumnSet(new string[] { "description" }));

                    if (!opportunity.Contains("description"))

                    {

                        throw new InvalidPluginExecutionException("You must provide a value for description.");

                    }

                    else

                    {

                        //throw new InvalidPluginExecutionException("none");

                    }

                }

                else

                {

                    throw new InvalidPluginExecutionException("none:opportunityid");

                }

            }

            else

            {

                throw new InvalidPluginExecutionException("none:PreWinOpportunity - OpportunityCloseWon");

            }

        }


PluginRegistration.exe



2016年6月2日 星期四

CRM2011 PluginRegistration Tool(Connect)

CRM2011 PluginRegistration Tool(Connect)

CRM Plugin登錄程式

1.Download Plugin Registration Tool
   https://www.microsoft.com/en-us/download/details.aspx?id=24004

2.Open PluginRegistration.exe
   C:\SDK\bin\PluginRegistration.exe

 


3.Connect CRM Server


4.double click Org Name Open


5. Your Plugins Assembly List












2015年12月9日 星期三

CRM2011 How to get Options Set Value in DataBase?

CRM2011 How to get Options Set Value in DataBase?



StringMap table
SELECT AttributeValue, Value
FROM StringMap
WHERE ObjectTypeCode = 1 -- entity type code 1 = account
AND AttributeName = 'statecode' --fieldname


Entity Type Code
SELECT EntityId, Name, ObjectTypeCode
FROM [MetadataSchema].[Entity]
ORDER BY Name

2015年12月8日 星期二

CRM2011 Get Entity/Attribute's Display Name from CRM database

CRM2011 Get Entity/Attribute's Display Name from CRM database
從資料庫取得CRM2011 Attribute Display Name







SELECT  EntityView.Name AS EntityName, LocalizedLabelView_1.Label AS EntityDisplayName,
       AttributeView.Name AS AttributeName, LocalizedLabelView_2.Label AS AttributeDisplayName
FROM    LocalizedLabelView AS LocalizedLabelView_2 INNER JOIN
       AttributeView ON LocalizedLabelView_2.ObjectId = AttributeView.AttributeId RIGHT OUTER JOIN
       EntityView INNER JOIN
       LocalizedLabelView AS LocalizedLabelView_1 ON EntityView.EntityId = LocalizedLabelView_1.ObjectId ON
       AttributeView.EntityId = EntityView.EntityId
WHERE   LocalizedLabelView_1.ObjectColumnName = 'LocalizedName'
 AND LocalizedLabelView_2.ObjectColumnName = 'DisplayName'
 AND LocalizedLabelView_1.LanguageId = '1033'
 AND LocalizedLabelView_2.LanguageId = '1033'
 AND EntityView.Name IN ('Account','Contact')
ORDER BY EntityName, AttributeName


reference from: http://jianwang.blogspot.tw/2009/03/get-entityattributes-display-name-from.html

2015年11月5日 星期四

CRM2011 使用Advanced Find取得Mail Regarding數量

CRM2011 使用Advanced Find取得Mail Regarding數量


指定下列兩個條件:
Activity Type Equals E-mail
Regarding Contains Data(like) Null



PS:
說明Regarding Contains Data(like) Null:
強制加入此條件不設定任何範圍,表示只要有Regarding Mail都會被找出來。如圖
以上Thanks

2015年7月7日 星期二

How to set Option set value to null CRM 2011




JavaScript:
function OnLoadForm(){
    setTwoOptionNull("new_tender");
}
function setTwoOptionNull(twoOption) {
    var isCreateForm = Xrm.Page.ui.getFormType() == 1;
    var twoOptionField = Xrm.Page.getAttribute(twoOption);
    var twoOptionValue = twoOptionField.getValue();
    if (isCreateForm) {
        twoOptionField.setValue(null); // set the value to null on create
        twoOptionField.setSubmitMode("always"); // required to store the null value
        document.getElementById("rad_" + twoOption + "1").onclick = function () { 
            if (twoOptionValue == false) {
                twoOptionField.setValue(true);
                twoOptionField.setValue(false);
            }
        }
    }
}

2015年2月12日 星期四

CRM 2011 Set the value of a field in JavaScript

CRM 2011 Set the value of a field in JavaScript

JavaScript:
function OnLoad()
{
   Xrm.Page.getAttribute("FieldSchemaName").setValue("Value");
}

CRM 2011 Get the value from a field in JavaScript

CRM 2011 Get the value from a field in JavaScript

JavaScript:
function OnLoad()
{
   var crmFieldValue = Xrm.Page.getAttribute("FieldSchemaName").getValue();
}

CRM 2011 Close the form in JavaScript

CRM 2011 Close the form in JavaScript

JavaScript:
function OnSave()
{
   Xrm.Page.ui.close();
}


/*** Other Sample ***/

function SaveAndClose()
{
    Xrm.Page.data.entity.save();
    if (parent.opener != undefined)
    {
        window.parent.close();
    }
    else
        Xrm.Page.ui.close();

}

CRM 2011 Get logged in User Id in JavaScript

CRM 2011 Get logged in User Id in JavaScript

JavaScript:
function OnLoad()
{
   var userId = Xrm.Page.context.getUserId();
}

CRM 2011 Get Organization Name in JavaScript

CRM 2011 Get Organization Name in JavaScript

JavaScript:
function OnLoad()
{
   var orgName = Xrm.Page.context.getOrgUniqueName();
}

CRM 2011 Hidden Tab in JavaScript

CRM 2011 Hidden Tab  in JavaScript

JavaScript:
function hiddenTab ()
{
    var statecode;
    var statecodeValue;  
    var visible = false;

    statecode = Xrm.Page.data.entity.attributes.get("statecode");  

    if (statecode != null && statecode.getValue() != null)
    {      
             statecodeValue = statecode.getValue();      
             if(statecodeValue != "1")          
             visible = true;  
    }

    Xrm.Page.ui.tabs.get('tab_3').setVisible(visible);
}

CRM 2011 Get the entityId in JavaScript, Get Current record ID

CRM 2011 Get the EntityId in JavaScript, Get Current record ID

JavaScript:
function OnLoad()
{
    var entityId = Xrm.Page.data.entity.getId();
}

CRM 2011 Get the Entity Name in JavaScript

CRM 2011 Get the Entity Name in JavaScript

JavaScript:
function OnLoad()
{
    var entityName = Xrm.Page.data.entity.getEntityName();
}

CRM 2011 Get Server url in JavaScript

CRM 2011 Get Server url in JavaScript

JavaScript:
function OnLoad()
{
   var serverUrl = Xrm.Page.context.getServerUrl();
}

CRM 2011 Save Code in JavaScript

CRM 2011 Save Code in JavaScript

JavaScript:
Xrm.Page.data.entity.save(); // for saving a record
Xrm.Page.data.entity.save("saveandclose"); // for save and close
Xrm.Page.data.entity.save("saveandnew"); // for save and new