Mscrm4 获取lookup的值

var lookupItem = new Array;
    lookupItem = crmForm.all.new_buildingid.DataValue;

    if (lookupItem[0] != null)
    {
       crmForm.all.new_name.DataValue=lookupItem[0].name;
    }

 

Posted in Web开发 at December 28, 2010. by 傻猫 .    Views: 3863    No Comments

mscrm 将自定义的视图在sitemap中显示

<SubArea Title="我已完成的任务"Id="nav_task01"Url="/Workplace/home_activities.aspx?type=task&viewid=%7bD70EA66D-4B41-DF11-B3AB-0026182FF465%7d"/>

 如下图mscrm_viewid.jpg

其中viewid可以用microsoft developer tool找到

Posted in Web开发 at December 28, 2010. by 傻猫 .    Views: 4340    No Comments

mscrm4 用js阻止表单保存

onsave 事件里
event.returnValue = window.confirm("是否要保存?");

Posted in Web开发 at December 28, 2010. by 傻猫 .    Views: 4283    No Comments

MSCRM4 ISV.Config

<ImportExportXml version="4.0.0.0" languagecode="1033" generatedBy="OnPremise">
<Entities></Entities>
<Roles></Roles>
<Workflows></Workflows>
 <IsvConfig>
  <configuration version="3.0.0000.0">
   <Root>
<!-- This section describes how to customize the area labels in the left pane in forms.
 <NavBarAreas>
  <NavBarArea Id="Sales">
   <Titles>
    <Title LCID="1033" Text="Customized Sales Label" />
    <Title LCID="1031" Text="Deush Sales Label" />
   </Titles>
  </NavBarArea>
  <NavBarArea Id="Service">
   <Titles>
    <Title LCID="1033" Text="Customized Service Label" />
   </Titles>
  </NavBarArea>
 </NavBarAreas>
-->
<!-- The main Global Menu Bar located at the top of all root level areas -->
    <MenuBar>
<!-- Custom Menus that appear between the Goto Menu and the Help Menu -->
     <CustomMenus>
      <Menu>
       <Titles>
        <Title LCID="1033" Text="ISV" />
       </Titles>
       <MenuItem Url="http://www.microsoft.com">
        <Titles>
         <Title LCID="1033" Text="New Window" />
        </Titles>
       </MenuItem>
       <MenuSpacer />
<!-- A horizontal drop-down menu spacer -->
       <SubMenu>
        <Titles>
         <Title LCID="1033" Text="ISV Tests" />
        </Titles>
        <MenuItem Url="http://www.microsoft.com" WinMode="2">
         <Titles>
          <Title LCID="1033" Text="Modeless Dialog" />
         </Titles>
        </MenuItem>
        <MenuSpacer />
        <MenuItem Url="http://www.microsoft.com" WinMode="1">
         <Titles>
          <Title LCID="1033" Text="Modal Dialog" />
         </Titles>
        </MenuItem>
        <MenuSpacer />
        <MenuItem JavaScript="alert('test');">
         <Titles>
          <Title LCID="1033" Text="Custom JavaScript" />
         </Titles>
        </MenuItem>
       </SubMenu>
      </Menu>
     </CustomMenus>
    </MenuBar>
<!-- Application Level Tool Bar -->
    <ToolBar>
     <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');">
      <Titles>
       <Title LCID="1033" Text="Test" />
      </Titles>
      <ToolTips>
       <ToolTip LCID="1033" Text="Info on Test" />
      </ToolTips>
     </Button>
     <ToolBarSpacer />
<!-- A vertical toolbar spacer -->
     <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');"
             Client="Web">
      <Titles>
       <Title LCID="1033" Text="Web Only" />
      </Titles>
      <ToolTips>
       <ToolTip LCID="1033"
                Text="Web client only. This will not appear in any Outlook pages." />
      </ToolTips>
     </Button>
     <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');"
             Client="Outlook" AvailableOffline="true">
      <Titles>
       <Title LCID="1033" Text="Outlook Only" />
      </Titles>
      <ToolTips>
       <ToolTip LCID="1033"
                Text="Outlook Only - This is available offline also." />
      </ToolTips>
     </Button>
     <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');"
             Client="Web, Outlook" AvailableOffline="true">
      <Titles>
       <Title LCID="1033" Text="Both" />
      </Titles>
      <ToolTips>
       <ToolTip LCID="1033"
                Text="Both Clients - This is available for both Web and Outlook Clients" />
      </ToolTips>
     </Button>
    </ToolBar>
   </Root>
<!-- Microsoft Customer Relationship Management Entities (Objects) -->
   <Entities>
    <Entity name="account">
     <MenuBar>
<!-- Custom Menus that you can add -->
      <CustomMenus>
       <Menu>
        <Titles>
         <Title LCID="1033" Text="ISV.NEW" />
        </Titles>
        <MenuItem Url="http://www.microsoft.com" PassParams="0"
                  WinMode="1">
         <Titles>
          <Title LCID="1033" Text="Coming Soon..." />
         </Titles>
        </MenuItem>
        <MenuSpacer />
        <SubMenu>
         <Titles>
          <Title LCID="1033" Text="Sub Test" />
         </Titles>
         <MenuItem Url="http://www.microsoft.com" PassParams="1">
          <Titles>
           <Title LCID="1033" Text="Test Sub 1" />
          </Titles>
         </MenuItem>
         <MenuSpacer />
         <MenuItem>
          <Titles>
           <Title LCID="1033" Text="Test Sub 2" />
          </Titles>
         </MenuItem>
        </SubMenu>
        <MenuSpacer />
        <MenuItem Url="http://www.microsoft.com" PassParams="0">
         <Titles>
          <Title LCID="1033" Text="Coming Soon..." />
         </Titles>
        </MenuItem>
        <MenuItem Client="Web">
         <Titles>
          <Title LCID="1033" Text="Web Only" />
         </Titles>
        </MenuItem>
        <MenuItem Client="Outlook" AvailableOffline="true">
         <Titles>
          <Title LCID="1033" Text="Outlook Only" />
         </Titles>
        </MenuItem>
        <MenuSpacer />
        <MenuItem ValidForCreate="0">
         <Titles>
          <Title LCID="1033" Text="Valid For Update Only" />
         </Titles>
        </MenuItem>
        <MenuItem ValidForUpdate="0">
         <Titles>
          <Title LCID="1033" Text="Valid For Create Only" />
         </Titles>
        </MenuItem>
       </Menu>
      </CustomMenus>
     </MenuBar>
<!-- The Account Tool Bar -->
     <ToolBar ValidForCreate="0" ValidForUpdate="1">
      <Button Icon="/_imgs/ico_18_debug.gif"
              Url="http://www.microsoft.com" PassParams="1"
              WinParams="" WinMode="0">
       <Titles>
        <Title LCID="1033" Text="asdf" />
       </Titles>
       <ToolTips>
        <ToolTip LCID="1033" Text="Info on Test" />
       </ToolTips>
      </Button>
      <ToolBarSpacer />
      <Button Icon="/_imgs/ico_18_debug.gif"
              Url="http://www.microsoft.com" PassParams="1" WinParams=""
              WinMode="1">
       <Titles>
        <Title LCID="1033" Text="Test" />
       </Titles>
       <ToolTips>
        <ToolTip LCID="1033" Text="Info on Test" />
       </ToolTips>
      </Button>
      <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');"
              Client="Web">
       <Titles>
        <Title LCID="1033" Text="Web Only" />
       </Titles>
       <ToolTips>
        <ToolTip LCID="1033" Text="Web client only. This will not appear in any Outlook pages." />
       </ToolTips>
      </Button>
      <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');"
              Client="Outlook" AvailableOffline="true">
       <Titles>
        <Title LCID="1033" Text="Outlook Only" />
       </Titles>
       <ToolTips>
        <ToolTip LCID="1033" Text="Outlook Only - This is available offline also." />
       </ToolTips>
      </Button>
     </ToolBar>
<!-- The Account Left Nav Bar -->
     <NavBar>
<!--
  Valid Areas Include
  ===================
  Sales
  Marketing
  Service
  Info
-->
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navItem">
       <Titles>
        <Title LCID="1033" Text="ISV Default" />
        </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navItemWeb"
                  Client="Web">
       <Titles>
        <Title LCID="1033" Text="ISV Web Only" />
       </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navItemOutlook"
                  Client="Outlook" AvailableOffline="true">
       <Titles>
        <Title LCID="1033" Text="ISV Outlook Only" />
       </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navSalesItem"
                  Area="Sales">
       <Titles>
        <Title LCID="1033" Text="ISV Sales" />
       </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navInfoItem"
                  Area="Info">
       <Titles>
        <Title LCID="1033" Text="ISV Info" />
       </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navMarketingItem"
                  Area="Marketing">
       <Titles>
        <Title LCID="1033" Text="ISV Marketing" />
       </Titles>
      </NavBarItem>
      <NavBarItem Icon="/_imgs/ico_18_debug.gif"
                  Url="http://www.microsoft.com" Id="navServiceItem"
                  Area="Service">
       <Titles>
        <Title LCID="1033" Text="ISV Service" />
       </Titles>
      </NavBarItem>
     </NavBar>
     <Grid>
      <MenuBar>
       <ActionsMenu>
        <MenuItem Url="http://www.microsoft.com" WinMode="1">
         <Titles>
          <Title LCID="1033" Text="Coming Soon..." />
         </Titles>
        </MenuItem>
        <MenuSpacer />
        <SubMenu>
         <Titles>
          <Title LCID="1033" Text="Sub Test" />
         </Titles>
         <MenuItem Url="http://www.microsoft.com">
          <Titles>
           <Title LCID="1033" Text="Test Sub 1" />
          </Titles>
         </MenuItem>
         <MenuSpacer />
         <MenuItem>
          <Titles>
           <Title LCID="1033" Text="Test Sub 2" />
          </Titles>
         </MenuItem>
         <MenuItem Client="Web">
          <Titles>
           <Title LCID="1033" Text="Web Only" />
          </Titles>
         </MenuItem>
         <MenuItem Client="Outlook" AvailableOffline="true">
          <Titles>
           <Title LCID="1033" Text="Outlook Only" />
          </Titles>
         </MenuItem>
        </SubMenu>
        <MenuItem Client="Web">
         <Titles>
          <Title LCID="1033" Text="Web Only" />
         </Titles>
        </MenuItem>
        <MenuItem Client="Outlook" AvailableOffline="true">
         <Titles>
          <Title LCID="1033" Text="Outlook Only" />
         </Titles>
        </MenuItem>
       </ActionsMenu>
       <Buttons>
        <Button Icon="/_imgs/ico_18_debug.gif"
                Url="http://www.microsoft.com" WinParams="" WinMode="2">
         <Titles>
          <Title LCID="1033" Text="Test" />
         </Titles>
         <ToolTips>
          <ToolTip LCID="1033" Text="Info on Test" />
         </ToolTips>
         </Button>
         <ToolBarSpacer />
         <Button Icon="/_imgs/ico_18_debug.gif"
                 Url="http://www.microsoft.com" WinParams="" WinMode="1">
          <Titles>
           <Title LCID="1033" Text="Test" />
          </Titles>
          <ToolTips>
           <ToolTip LCID="1033" Text="Info on Test" />
          </ToolTips>
         </Button>
         <Button Icon="/_imgs/ico_18_debug.gif"
                 JavaScript="alert('test');" Client="Web">
          <Titles>
           <Title LCID="1033" Text="Web Only" />
          </Titles>
          <ToolTips>
           <ToolTip LCID="1033" Text="Web client only. This will not appear in any Outlook pages." />
          </ToolTips>
         </Button>
         <Button Icon="/_imgs/ico_18_debug.gif"
                 JavaScript="alert('test');" Client="Outlook"
                 AvailableOffline="true">
          <Titles>
           <Title LCID="1033" Text="Outlook Only" />
          </Titles>
          <ToolTips>
           <ToolTip LCID="1033" Text="Outlook Only - This is available offline also." />
          </ToolTips>
         </Button>
        </Buttons>
       </MenuBar>
      </Grid>
     </Entity>
      <Entity name="contact" />
      <Entity name="lead" />
      <Entity name="opportunity" />
      <Entity name="list" />
      <Entity name="campaign" />
      <Entity name="campaignactivity" />
      <Entity name="campaignresponse" />
      <Entity name="incident" /><!-- Case -->
      <Entity name="quote" />
      <Entity name="salesorder" /><!-- Order -->
      <Entity name="invoice" />
      <!-- Custom Entities -->
      <!-- <Entity name="new_myentity"/> -->
      <!-- End Custom Entities -->
    </Entities>
<!-- Microsoft Customer Relationship Management Service Management Customization -->
   <ServiceManagement>
    <AppointmentBook>
     <SmoothScrollLimit>2000</SmoothScrollLimit>
     <TimeBlocks>
<!-- All CSS Class mapping for Service activities -->
      <TimeBlock EntityType="4214" StatusCode="1"
                 CssClass="ganttBlockServiceActivityStatus1" />
      <TimeBlock EntityType="4214" StatusCode="2"
                 CssClass="ganttBlockServiceActivityStatus2" />
      <TimeBlock EntityType="4214" StatusCode="3"
                 CssClass="ganttBlockServiceActivityStatus3" />
      <TimeBlock EntityType="4214" StatusCode="4"
                 CssClass="ganttBlockServiceActivityStatus4" />
      <TimeBlock EntityType="4214" StatusCode="6"
                 CssClass="ganttBlockServiceActivityStatus6" />
      <TimeBlock EntityType="4214" StatusCode="7"
                 CssClass="ganttBlockServiceActivityStatus7" />
      <TimeBlock EntityType="4214" StatusCode="8"
                 CssClass="ganttBlockServiceActivityStatus8" />
      <TimeBlock EntityType="4214" StatusCode="9"
                 CssClass="ganttBlockServiceActivityStatus9" />
      <TimeBlock EntityType="4214" StatusCode="10"
                 CssClass="ganttBlockServiceActivityStatus10" />
<!-- All CSS Class mapping for Appointments -->
      <TimeBlock EntityType="4201" StatusCode="1"
                 CssClass="ganttBlockAppointmentStatus1" />
      <TimeBlock EntityType="4201" StatusCode="2"
                 CssClass="ganttBlockAppointmentStatus2" />
      <TimeBlock EntityType="4201" StatusCode="3"
                 CssClass="ganttBlockAppointmentStatus3" />
      <TimeBlock EntityType="4201" StatusCode="4"
                 CssClass="ganttBlockAppointmentStatus4" />
      <TimeBlock EntityType="4201" StatusCode="5"
                 CssClass="ganttBlockAppointmentStatus5" />
      <TimeBlock EntityType="4201" StatusCode="6"
                 CssClass="ganttBlockAppointmentStatus6" />
     </TimeBlocks>
    </AppointmentBook>
   </ServiceManagement>
  </configuration>
 </IsvConfig>
 <EntityMaps />
 <EntityRelationships />
 <Languages>
  <Language>1033</Language>
 </Languages>
</ImportExportXml>

Posted in Web开发 at December 28, 2010. by 傻猫 .    Views: 4292    No Comments

控制MSCRM4菜单栏

修改_root/bar_top.aspx文件,在文件末尾添加以下代码,可以达到隐藏菜单的效果。

<script type="text/javascript">
document.getElementById("mnu_new_activity").style.display="none";
document.getElementById("mnu_new_record").style.display="none";
document.getElementById("btn_download_olk").style.display="none";
document.getElementById("help").style.display="none";
document.getElementById("btn_advfind").style.display="none";
document.getElementById("goto").style.display="none";
document.getElementById("tools").style.display="none";
</script>

mnu_new_activity 新建活动
mnu_new_record  新建记录
goto  转至
tools 工具
btn_advfind  高级查找
btn_download_olk  CRM For Outlook
help   帮助

mscrm4菜单栏.jpg

Posted in Web开发 at December 28, 2010. by 傻猫 .    Views: 4939    No Comments

MSCRM4 隐藏按钮方法

///////////////////////////////////隐藏  将现有客户收费单添加到此记录 按钮//////////////////////////////////////////newnewkhjbxxnewkhsfd
//客户收费单
HideAssociatedViewButtons('new_new_khjbxx_new_khsfd',  ['_MBtoplocAssocOneToMany10040newnewkhjbxxnewkhsfd']); 
//客户证件信息
HideAssociatedViewButtons('new_new_khjbxx_new_khzjxx', ['_MBtoplocAssocOneToMany10074newnewkhjbxxnewkhzjxx']);
//客户帐号信息
HideAssociatedViewButtons('new_new_khjbxx_new_khzhxx', ['_MBtoplocAssocOneToMany10043newnewkhjbxxnewkhzhxx']);

//延期客户信息
HideAssociatedViewButtons('new_new_khjbxx_new_yqkhxx', ['_MBtoplocAssocOneToMany10060newnewkhjbxxnewyqkhxx','_MBcrmGridPrint','_MBcrmGridExportToExcel','_MBWebMailMergecrmGrid10060'
,'_MBdoActioncrmGrid10060assign','_MBdoActioncrmGrid10060delete','MoreActions']);


//-----------------------------------隐藏帧里的按钮----------------------
//-----------------------------------by 王大勇 2010-12-24----------------
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function HideAssociatedViewButtons(loadAreaId, HideEleIDs) {
    var navElement = document.getElementById('nav_' + loadAreaId);
    if (navElement != null) {
        navElement.onclick = function LoadAreaOverride() {
            // Call the original CRM method to launch the navigation link and create area iFrame
            loadArea(loadAreaId);
            HideViewButtons(document.getElementById(loadAreaId + 'Frame'), HideEleIDs);
        }
    }
}

function HideViewButtons(Iframe, HideEleIDs) {
    if (Iframe != null) {
        Iframe.onreadystatechange = function HideTitledButtons() {
            if (Iframe.readyState == 'complete') {
                var iFrame = frames[window.event.srcElement.id]; //var liElements = iFrame.document.getElementsByTagName('li');     
    
    for (var j = 0; j < HideEleIDs.length; j++) {
                  iFrame.document.getElementById(HideEleIDs[j]).style.display = 'none';
                }
    
            }
        }
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Posted in Web开发 at December 24, 2010. by 傻猫 .    Views: 4115    No Comments

CRM中代码自动共享

// Create the SecurityPrincipal Object
    SecurityPrincipal principal = new SecurityPrincipal();
    principal.Type = SecurityPrincipalType.User;

    // PrincipalId is the Guid of the user to whom access is being granted
    // SDK:principal.PrincipalId = new Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");
    principal.PrincipalId = otherUserId;

    // Create the PrincipalAccess Object
    PrincipalAccess principalAccess = new PrincipalAccess();

    // Set the PrincipalAccess Object's Properties
    principalAccess.Principal = principal;

    // Gives the principal access to read
    principalAccess.AccessMask = AccessRights.ReadAccess;
   
    // Create the Target Object for the Request
    TargetOwnedAccount target = new TargetOwnedAccount();

    // EntityId is the Guid of the account access is being granted to
    // SDK:target.EntityId = new Guid("6A92D3AE-A9C9-4E44-9FA6-F3D5643753C1");
    target.EntityId = created.id;

    // Create the Request Object
    GrantAccessRequest grant = new GrantAccessRequest();

    // Set the Request Object's properties
    grant.PrincipalAccess = principalAccess;
    grant.Target = target;

    // Execute the Request
    GrantAccessResponse granted = (GrantAccessResponse)service.Execute(grant);

Posted in Web开发 at December 24, 2010. by 傻猫 .    Views: 5596    1 Comment

MSCRM4获取选择记录的guid

一、更改配置文件。

ISV路径:ImportExportXml/IsvConfig/configuration/Entities/Entity name="account"/Grid/MenuBar/Buttons

在配置文件中添加以下XML代码:

<Button 
   Icon="/_imgs/ico_18_debug.gif" 
   Url="/ISV/test.htm" 
   WinMode="2"
>
   <Titles>
      <Title LCID="1033" Text="Get GUIDS" />
   </Titles>
   <ToolTips>
      <ToolTip LCID="1033" Text="Get GUIDS for selected records" />
   </ToolTips>
</Button>

二、编写代码

在isv文件夹下新建 test.html 文件,js代码如下:

<html>
   <head>
      <title>GUIDs for records seleced in Grid</title>
      <script type="text/jscript">
         function listselecteditems()
         {
            var placeholder = document.getElementById("test");
            var sGUIDValues = "";
            var selectedValues;
            //Make sure window.dialogArguments is available.
            if (window.dialogArguments)
            {
               selectedValues = new Array(window.dialogArguments.length -1);
            }
            else
            {
               placeholder.innerText = "window.dialogArguments is not available.";
               return
            }
            selectedValues = window.dialogArguments;
            if (selectedValues != null)
            {
               for (i=0; i < selectedValues.length; i++)
               {
                  sGUIDValues += selectedValues[i] +"\n";
               }
               placeholder.innerText = sGUIDValues;
            }
            else
            {
               placeholder.innerText = "No records were selected.";
            }
         }
      </script>
   </head>
   <body onload="listselecteditems()">
   <div id="test"></div>
   </body>
</html>

事例图片:

 

 

 

Posted in Web开发 at December 24, 2010. by 傻猫 .    Views: 4118    No Comments