简体   繁体   中英

Javascript is not triggering from Ribbon button in crm 2011?

i have created 2 ribbon buttons inside the appointment entity,the functionality of these buttons are ,while clicking it will open a new phone call and task respectively, but task is not getting opened.Phone call is working fine.Please suggest..

Please see the RibbonDiffxml

<RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="test.Form.appointment.MainTab.Include.AddExisting.CustomAction" 

Location="Mscrm.Form.appointment.MainTab.Include.Controls._children" Sequence="41">
            <CommandUIDefinition>
              <Button Id="test.Form.appointment.MainTab.Include.AddExisting" Command="test.Form.appointment.MainTab.Include.AddExisting.Command" Sequence="9" 

ToolTipTitle="$LocLabels:test.Form.appointment.MainTab.Include.AddExisting.LabelText" 

LabelText="$LocLabels:test.Form.appointment.MainTab.Include.AddExisting.LabelText" 

ToolTipDescription="$LocLabels:test.Form.appointment.MainTab.Include.AddExisting.Description" TemplateAlias="o1" 

Image16by16="/_imgs/ribbon/AddExistingStandard_16.png" Image32by32="/_imgs/ribbon/AddExistingStandard_32.png" />
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="test.Form.appointment.MainTab.Include.addphone.CustomAction" Location="Mscrm.Form.appointment.MainTab.Include.Controls._children" 

Sequence="41">
            <CommandUIDefinition>
              <Button Id="test.Form.appointment.MainTab.Include.addphone" Command="test.Form.appointment.MainTab.Include.addphone.Command" Sequence="8" 

ToolTipTitle="$LocLabels:test.Form.appointment.MainTab.Include.addphone.LabelText" 

LabelText="$LocLabels:test.Form.appointment.MainTab.Include.addphone.LabelText" 

ToolTipDescription="$LocLabels:test.Form.appointment.MainTab.Include.addphone.Description" TemplateAlias="o1" Image16by16="/_imgs/ribbon/entity16_4210.png" 

Image32by32="/_imgs/ribbon/entity32_4210.png" />
            </CommandUIDefinition>
          </CustomAction>
          <CustomAction Id="test.Form.appointment.MainTab.Include.AddTask.CustomAction" Location="Mscrm.Form.appointment.MainTab.Include.Controls._children" 

Sequence="41">
            <CommandUIDefinition>
              <Button Id="test.Form.appointment.MainTab.Include.AddTask" Command="test.Form.appointment.MainTab.Include.AddTask.Command" Sequence="10" 

ToolTipTitle="$LocLabels:test.Form.appointment.MainTab.Include.AddTask.LabelText" 

LabelText="$LocLabels:test.Form.appointment.MainTab.Include.AddTask.LabelText" 

ToolTipDescription="$LocLabels:test.Form.appointment.MainTab.Include.AddTask.Description" TemplateAlias="o1" Image16by16="/_imgs/ribbon/entity16_4212.png" 

Image32by32="/_imgs/ribbon/entity32_4212.png" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="test.Form.appointment.MainTab.Include.AddExisting.Command">
            <EnableRules />
            <DisplayRules />
            <Actions>
              <Url WinMode="0" Address="$webresource:testes_TaskPhoneCallLookup">
                <CrmParameter Value="FirstPrimaryItemId" Name="data" />
              </Url>
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="test.Form.appointment.MainTab.Include.addphone.Command">
            <EnableRules />
            <DisplayRules />
            <Actions>
              <JavaScriptFunction FunctionName="createPhone" Library="$webresource:testcrm_/Scripts/test.Wealthmgmt.Appointment.Buttons" />
            </Actions>
          </CommandDefinition>
          <CommandDefinition Id="test.Form.appointment.MainTab.Include.AddTask.Command">
            <EnableRules />
            <DisplayRules />
            <Actions>
              <JavaScriptFunction FunctionName="createTask" Library="$webresource:testcrm_/Scripts/test.Wealthmgmt.Appointment.Buttons" />
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules />
          <EnableRules />
        </RuleDefinitions>
<LocLabels>
          <LocLabel Id="test.Form.appointment.MainTab.Include.AddExisting.Description">
            <Titles>
              <Title languagecode="1033" description="Add Task and Phone Call" />
            </Titles>
          </LocLabel>
          <LocLabel Id="test.Form.appointment.MainTab.Include.AddExisting.LabelText">
            <Titles>
              <Title languagecode="1033" description="Add Existing Activity" />
            </Titles>
          </LocLabel>
          <LocLabel Id="test.Form.appointment.MainTab.Include.addphone.Description">
            <Titles>
              <Title languagecode="1033" description="Add a new phone call" />
            </Titles>
          </LocLabel>
          <LocLabel Id="test.Form.appointment.MainTab.Include.addphone.LabelText">
            <Titles>
              <Title languagecode="1033" description="Add Phone Call" />
            </Titles>
          </LocLabel>
          <LocLabel Id="test.Form.appointment.MainTab.Include.AddTask.Description">
            <Titles>
              <Title languagecode="1033" description="Add new Task" />
            </Titles>
          </LocLabel>
          <LocLabel Id="test.Form.appointment.MainTab.Include.AddTask.LabelText">
            <Titles>
              <Title languagecode="1033" description="Add Task" />
            </Titles>
          </LocLabel>
        </LocLabels>
      </RibbonDiffXml>

And Javascript is

function createTask(){


var guidCaller=Xrm.Page.data.entity.getId();
//alert(guidCaller);
var orgName = Xrm.Page.context.getServerUrl();
var extraqs = "&subject=New Task";
extraqs += "&hpcrm_timeblockid="+guidCaller;
var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
window.open(orgName+"main.aspx?etn=task&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs), "_blank", features, false);


}


function createPhone(){

var guidCaller=Xrm.Page.data.entity.getId();
//alert(guidCaller);
var orgName = Xrm.Page.context.getServerUrl();
var extraqs = "&subject=New Phone Call";
extraqs += "&hpcrm_timeblockid="+guidCaller;
var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
window.open(orgName+"main.aspx?etn=phonecall&pagetype=entityrecord&extraqs=" + encodeURIComponent(extraqs), "_blank", features, false);

}

I'm guessing something isn't deployed quite right. Put a break point in your ribbon javascript using the debugger (F12) for both createTask() and create createPhone() . If your breakpoint gets hit for the phoecall, but not the task, you should probably attempt to redeploy your ribbon XML. If you're break point gets hit, it is probably a javascript error, step though it and figure it out.

NOTE! The name of the javascript file to set your break point won't be test.Wealthmgmt.Appointment.Buttons. It will be script block (some random number).

i have faced this before.. try to reset IIS and then refresh your page..if the same

behavior still exists you should make sure that the function is called and to do so you

should put an alert in first line of the function and if the behavior still exists re-deploy

the solution again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM