CRM 2011 -CUSTOMIZATIONS.xml KULANARAK RİBBONA BUTON EKLEME, CUSTOMRULE ve BUTONA TIKLAYINCA CUSTOM ASPX AÇMA


Solution ı kullanarak hangi entity e buton ekleyeceksek o entity nin customizations.xml i indirilir.Daha sonra <RibbonDiffXml> tagını asagıdakı gıbı degıstırınız.WebResource da List_main_library.js adlı javascript library si olusturdum ve içerigine kullanacagım fonksiyonlarımı yazdım.(Javascript kodları sayfanın altındadır.)


<RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.CustomAction" Location="Mscrm.Form.list.MainTab.Actions.Controls._children" Sequence="41">
            <CommandUIDefinition>
              <Button Id="Okalip.Form.list.MainTab.Actions.CreateListonEuroMessage" Command="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Command" Sequence="29" ToolTipTitle="$LocLabels:Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.LabelText" LabelText="$LocLabels:Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.LabelText" ToolTipDescription="$LocLabels:Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Description" TemplateAlias="o1" Image16by16="/_imgs/ribbon/convert_16.png" Image32by32="/_imgs/ribbon/convert_32.png" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinitionId="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Command">
            <EnableRules>
              <EnableRule Id="Okalip.Form.list.MainTab.Actions.CreateListonEuroMessage.Command.EnableRule.AGC" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Command.DisplayRule.FormStateRule" />
            </DisplayRules>
            <Actions>
             <JavaScriptFunction FunctionName="CreateListonEuroMessageOnClick" Library="$webresource:List_main_library.js" />
              <!--<Url Address ="http://www.google.com" />-->/*direkt url verme*/
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules>
            <DisplayRule Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Command.DisplayRule.FormStateRule">
              <FormStateRule State="Create" Default="true" InvertResult="true" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules>
            <EnableRule Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Command.EnableRule.AGC">
              <CustomRule FunctionName="CreateListonEuroMessageEnable" Library="$webresource:List_main_library.js" Default="false" InvertResult="true" />
            </EnableRule>
          </EnableRules>
        </RuleDefinitions>
        <LocLabels>
          <LocLabel Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.Description">
            <Titles>
              <Title languagecode="1033" description="CreateListonEuroMessage Description" />
              <Title languagecode="1055" description="Euromessage arayüzünde liste olustur." />
            </Titles>
          </LocLabel>
          <LocLabel Id="Gokhan.Form.list.MainTab.Actions.CreateListonEuroMessage.LabelText">
            <Titles>
              <Title languagecode="1033" description="Create List on EuroMessage" />
              <Title languagecode="1055" description="Liste olustur" />
            </Titles>
          </LocLabel>
        </LocLabels>
      </RibbonDiffXml>


List_main_library.js javascript kodları

function CreateListonEuroMessageEnable() {
    return true;
/*Geriye donus degeri True gonderılırse buton disable,false gonderılırse buton enable olacaktır.Burada işlemlerinizi yapıp ,işleme gore true,false geriye deger gonderılır*/
}

/*Gokhan Mentese*/
function CreateListonEuroMessageOnClick() {
    var _userId = Xrm.Page.context.getUserId();
    var entityid = Xrm.Page.data.entity.getId();
    var orgname = Xrm.Page.context.getOrgUniqueName();

    if (_userId != null && entityid != null && orgname != null) {
        var url = null;
        if (orgname != null) {
            url = "http://localhost:8083/OnlyCreateList.aspx?userid=" + _userId + "&entityid=" + entityid + "&orgname=" + orgname;
/*Iss üzerinde calısan site deki OnlyCreateList.aspx sayfamı cagırıyorum.Beraberınde query string de yolluyorum */
        }
        if (url != null) {
            var features = 'height=300,width=450,left=300,top=150,resizable=yes,titlebar=no,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=no';
            window.open(url, 'GokhanMentese', features);
        }
    }
}


Hiç yorum yok:

Yorum Gönder