CRM 2011 Sales Literature Add Attachment

0 comments


How you add attachment from Sales Literature ?

Sales Literature Entity -> Sales Attachment -> Add New Attachment -> Attach Video,Photo and Others.

CRM 2011 Related Entity Numbering/ Calculate Amount Of Related Entity Records

0 comments


Problem:
-I need to c amount of related entity B tied to parent entity A.
-1 Entity A : Many Entity B
-Need auto numbering on amount of related record (entity B) tied to entity A.

Solution:
-Add function during onLoad();
-Add one ref javascript Name Navi_AutoNumber.js

eg. onLoad Script


function onLoad() {
    GetAssociatedRecords("Entity B Name", "Entity B Look Up Field Scheme Name", "Relation Name");


eg. Navi_AutoNumber.js


function GetAssociatedRecords(associatedEntityName, primaryIdSchemaName, relationshipSchemaName){
try{
if(Xrm.Page.data.entity.getId() != null){
var bProceed = false;
var nav = 'nav_' + relationshipSchemaName;
var items = Xrm.Page.ui.navigation.items.get();
for (var i in items) {
var item = items[i];
if(item.getId().toLowerCase() == nav.toLowerCase()){
bProceed = true;
break;
}
}

if(bProceed){
var relationshipIdvalue = Xrm.Page.data.entity.getId();
var columns = [];    
   var Filter = primaryIdSchemaName + "/Id eq (guid'" + relationshipIdvalue + "')"
   var Collection = CrmRestKit.RetrieveMultiple(associatedEntityName, columns, Filter);    
   var totalRecords = Collection.results.length;
       
   if(document.getElementById(nav) != null)
   {
    document.getElementById(nav).getElementsByTagName('NOBR')[0].innerText = " (" + totalRecords + ")" + document.getElementById(nav).getElementsByTagName('NOBR')[0].innerText   ;
   }    
   //return Collection;
   }
   }
    }catch(err){
    alert(err);
    }
}

How it will look Like



Free Convert AVI to MP4 Link

0 comments


Convert AVI to MP4 Link
- If u need software to convert AVI file to MP4

Free Youtube Downloader Link

0 comments


Free Youtube Downloader

- If u need download youtube video.

CRM 2011 CrmEncodeDecode is Undefined

0 comments



Problem: 
CrmEncodeDecode is Undefined

Solution:
parent.CrmEncodeDecode.CrmXmlEncode(sFetchXml);

I put parent infront of CrmEncodeDecode because im using it in webpage and i need to call
parent page only i can load the CrmEncodeDecode.


Webpage act as a child for a record form.That mean every webpage if u need to use the field value,
there need to put parent infront of all the crm code.

eg. parent.Xrm.Page.data.entity.attributes("fieldname").getValue();

CRM 2011 Webpage To Auto Play Video Link/ Youtube Video Link

0 comments


*Note Using HTML code In Webpage


<HTML><HEAD>
<META charset=utf-8></HEAD>
<BODY contentEditable=true>

<IFRAME class=youtube-player style="width:100%;height:100%" src="youtubelinks?wmode=opaque&autoplay=1&enablejsapi=1" frameBorder=0 type="text/html"></IFRAME>

</BODY></HTML>

autoplay = to configure once onload to play the video or not

CRM 2011 Refresh Webpage

0 comments


.eg Javascript

var wrControl = Xrm.Page.ui.controls.get("Webresource_WebpageName");
wrControl.setSrc(wrControl.getSrc());

CRM 2011 Refresh SubGrid

0 comments


eg. Javascript

gridControl = Xrm.Page.ui.controls.get("SubGrid_Name");
gridControl.refresh();


CRM 2011 Button To Open New Page

0 comments


Problem:
How do i write html in javascript and open the webpage.

Solution:
eg. Javascript


function newPage(){
var newWin = open('url','_blank','fullscreen=yes,directories=no,menubar=no,location=no,toolbar=no,status=no,scrollbars=yes­,resizable=yes');
newWin.document.open();
newWin.document.write('<HTML>');
newWin.document.write('<HEAD>');
newWin.document.write('<style type="text/css">');
    newWin.document.write('#map {');
    newWin.document.write('height: 100%;');
    newWin.document.write('width: 100%;');
    newWin.document.write('border: 1px solid #000;');
    newWin.document.write('}');
    newWin.document.write('</style>');
newWin.document.write('</HEAD>');
newWin.document.write('<BODY>');
newWin.document.write('<iframe id="map" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.com&amp;output=embed"></iframe>');
newWin.document.write('</BODY>');
newWin.document.write('</HTML>');
newWin.document.close();
}

Call these function under any trigger point. As for me i used it under onclick event from a button.

CRM 2011 Add JScript into Button Event JScript

0 comments


Problem:
I created a custom ribbon button. The button added with onclick event function eg. GenerateNumbering.
The problem is i need to add another Javascript as Ref toward another javascript.
I used Visual Ribbon Editor to edit and create the custom button and only one Javascript can be insert into it.
That mean i cant call another javascript as reference.

Solution:
I Created a solution with the entity that i need to customize the ribbon button.
Export out the solution and edit the customization by adding in some javascript to call.
Eg.

Editing the xml in these section


<CommandDefinition Id="vwork.SubGrid.vw_outlet.MainTab.Layout.GenerateRoute.Command">
<EnableRules />
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="isNaN" Library="$webresource:YourScriptName" />
<JavaScriptFunction FunctionName="isNaN" Library="$webresource:YourScriptName" />
<JavaScriptFunction FunctionName="isNaN" Library="$webresource:YourScriptName" />
<JavaScriptFunction Library="$webresource:YourScriptName" FunctionName="GenerateNumbering"/>
</Actions>
</CommandDefinition>

Save the customization xml, zipped it and import it back to the organization.
You can now call different function in other javascript u included above.

Thanks.
Hope my solution helps

CRM 2011 Retrieve Related Record SelectedID from SubGrid

0 comments


Problem: 
How to retrieve the selected record from related entities subgrid ?
I wan to use a button to get all the selected record id.

Solve Method:
1. Create one button to call java script upon clicked.
eg.

function GenerateRoute(AllSelectedId) { debugger; var Answer = AllSelectedId; }

2. Import and export out solution and modify the solution customization.
Adding "<CrmParameter Value="SelectedControlSelectedItemIds" /> " under Javascript XML.


<Actions>
<JavaScriptFunction Library="$webresource:Route.js" FunctionName="Generate" >
<CrmParameter Value="SelectedControlSelectedItemIds" /> 
</JavaScriptFunction> 
</Actions>

3. Import back the zipped solution. And test run by selecting the particular record.

4. Final Generate and get the result. All the selected record from related entities subgrid are retrieve.

eg Javascript function
function Generate(AllSelectedId) { }

all the selected id will populate into AllSelectedId as array.

Thanks. Hope my solution helps

CRM 2011 Refreshing a Web Resource/Webpage On A Form

0 comments


I have problem with refreshing a custom webpage.
Below will be the function i use to refresh the webpage on particular trigger point.

var someOnchangeEvent = function(){
    var wrControl = Xrm.Page.ui.controls.get("nameofwebresoucecontrol");
    wrControl.setSrc(wrControl.getSrc());
}

CRM 2011 Get Organization ID

0 comments


Using SQL Server Management Studio.

Create new query as below:

Select * from MSCRM_CONFIG..Organization

CRM 2011 Get Dropdown Value/ Dropdown Text

0 comments


Below is the script to retrieve dropdown value and text.

To get text

Xrm.Page.data.entity.attributes.get("vw_facilitiestype").getSelectedOption().text
Xrm.Page.data.entity.attributes.get("vw_facilitiestype").getText()

To get value
Xrm.Page.data.entity.attributes.get("vw_facilitiestype").getSelectedOption().value
Xrm.Page.data.entity.attributes.get("vw_facilitiestype").getValue();

CRM 2011 Duplicate Function to Duplicate Record

0 comments


Problems: How easily can i create a record if the record is nearly same as another record? Whereby i no need to key in everything again,

Solution:
This function is called by using one custom button.


function Duplicatet() {

    var Id = Xrm.Page.data.entity.getId();
    var Name = Xrm.Page.data.entity.attributes.get("vw_name").getValue();
    var Status = Xrm.Page.data.entity.attributes.get("vw_status").getValue();
    var PurchaseDate = FormatDate("vw_purchasedate");
    if (Xrm.Page.data.entity.attributes.get("vw_parentassetnoid").getValue() != null) {
    var ParentAssetNoId = Xrm.Page.data.entity.attributes.get("vw_parentassetnoid").getValue()[0].id;
    var ParentAssetNoIdName = Xrm.Page.data.entity.attributes.get("vw_parentassetnoid").getValue()[0].name;
    var ParentAssetNoIdType = Xrm.Page.data.entity.attributes.get("vw_parentassetnoid").getValue()[0].entityType;
    }

    //define default values for new Incident record
    var parameters = {};
    
    if (Name != null) { parameters["vw_name"] = Name + " - COPY"; }
    if (AsseTagNo != null) { parameters["vw_assettagno"] = AssetTagNo; }
    if (Status != null) { parameters["vw_status"] = Status; }
    if (Condition != null) { parameters["vw_condition"] = Condition; }
    if (ParentAssetNoId != null && ParentAssetNoIdName != null) { parameters["vw_parentassetnoid"] = ParentAssetNoId; parameters["vw_parentassetnoidname"] = ParentAssetNoIdName; }
    if (PurchaseDate != null) { parameters["vw_purchasedate"] = PurchaseDate; }
  
    //pop form with default values
    Xrm.Utility.openEntityForm("EntityName", null, parameters);
}

// This function takes the fieldname of a date field as input and returns the value of that field in MM/DD/YYYY format
// Note: the day, month and year variables are numbers
function FormatDate(fieldname) {
    var d = Xrm.Page.data.entity.attributes.get(fieldname).getValue();
    if (d != null) {
        var curr_date = d.getDate();
        var curr_month = d.getMonth();
        curr_month++;  // getMonth() considers Jan month 0, need to add 1
        var curr_year = d.getFullYear();
        return curr_month + "/" + curr_date + "/" + curr_year;
    }
    else return null;
}


*Note this function cannot return form with a lot of field. Because this function pass parameter through url and there limitation on url max character.

CRM 2011 Get Last Two Character/ Last Character

0 comments


Have you ever encounter problems such as request for date format to be MMYY or YYMM?
Below i added JavaScript to cater for the problem.


function GenerateYYMM() {

var newvalueMonth;
var valueMonth = new Date().getMonth() + 1;
var valueYear = new Date().getFullYear();

        //get the last 2 character of year
var valueYearLength = valueYear.toString().length;
var YearToString = valueYear.toString();
var last_char=YearToString.charAt(valueYearLength-1);
var Before_last_char=YearToString.charAt(valueYearLength-2);
var LastTwoYearChar = Before_last_char + last_char;

        //get the last 2 character of month with length 2
var valueMonthLength = valueMonth.toString().length;
if (valueMonthLength != 2) {newvalueMonth = "0" + valueMonth.toString();}
else {newvalueMonth = valueMonth.toString();}

var NewYYMM = LastTwoYearChar + newvalueMonth;
return NewYYMM;
}

*Note based on today date. U can use this on any date field too.