CRM 2011 Use Microsoft Translator To Translate Text In CRM (Button on Ribbon)

0 comments


Problem with translating. Here your solution by creating a ribbon button to translate.

Click Here To Direct To The Link:
Button To Translate

CRM 2011 Error On Editing Multiple Record

0 comments


*Note edit multiple record method


 //Will be having error during bulk edit/ multiple edit.
 function onload() {
    hideSections("vw_assettype", "Asset");
    hideSections("vw_purchasetype", "Hire");
 }

//Free from having error during bulk edit/ multiple edit.

 function onLoad() {
    hideSections("vw_assettype", "Asset");
    hideSections("vw_purchasetype", "Hire");
 }


Take note
This is what i tested and retrieve from when i use onload script on my javascript to trigger at form load event handlers. The bulk edit will prompt out error message.

Error msg such as unable to edit the form. It is javascript error. 

I check and check at last the error was on the word onload on form load event handler. When i change the onload to onLoad the bulk edit and everything work perfectly.

Event handlers Onload Event with javascript onload. The alphabet l in onload is not in capital.
Event handlers Onload Event with javascript onLoad. The alphabet L in onLoad is in capital.

CRM 2011 Record Duplication Ribbon

0 comments


*Note used by passing parameter through url. Trigger point will be custom ribbon button.

Before:
Make sure created one ribbon button name as duplicate to call this javascript function.

Javascript Function:


function DuplicateAsset() {

    var AssetId = Xrm.Page.data.entity.getId();

    var AssetName = Xrm.Page.data.entity.attributes.get("vw_name").getValue(); //Single Text
    var Administrator = Xrm.Page.data.entity.attributes.get("vw_administrator").getValue(); //Dropdown
    if (Xrm.Page.data.entity.attributes.get("vw_custodian").getValue() != null) { //Lookup 
    var CustodianId = Xrm.Page.data.entity.attributes.get("vw_custodian").getValue()[0].id;
    var CustodianName = Xrm.Page.data.entity.attributes.get("vw_custodian").getValue()[0].name;
    var CustodianType = Xrm.Page.data.entity.attributes.get("vw_custodian").getValue()[0].entityType;
    }
    var InvoiceDate = FormatDate("vw_invoicedate"); //Date

    //define default values for new Incident record
    var parameters = {};
   
if (AssetName != null) { parameters["vw_name"] = AssetName + " - COPY"; }
    if (Administrator != null) { parameters["vw_administrator"] = Administrator; }
    if (CustodianId != null && CustodianName != null) { parameters["vw_custodian"] = CustodianId; parameters["vw_custodianname"] = CustodianName; }
    if (InvoiceDate != null) { parameters["vw_invoicedate"] = InvoiceDate; }

    //pop form with default values
    Xrm.Utility.openEntityForm("Entity Name", 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;
}


This code work when u key in the field with the value or without value.
One duplicate record will pop out for u to save and edit.

Limitation: 
Url character had their limit of character. If u hit the amount of character then this code wont work anymore.

CRM 2011 Generate Year and Month In 4 Character

0 comments


*Note generate date and year as eg:1209


function GenerateAutoNumYYMM() {

var newvalueMonth;
var d = new Date();  //Today Date
var valueMonth = new Date().getMonth() + 1;  //Value month need to +1
var valueYear = new Date().getFullYear();

var valueYearLength = valueYear.toString().length; //Get the length
var YearToString = valueYear.toString(); //Convert to string

var last_char=YearToString.charAt(valueYearLength-1);  //Get last character
var Before_last_char=YearToString.charAt(valueYearLength-2);  //Get last second character

var LastTwoYearChar = Before_last_char + last_char; //Get last two character

var valueMonthLength = valueMonth.toString().length; //get month length
 
if (valueMonthLength != 2) {
newvalueMonth = "0" + valueMonth.toString(); //Convert to string
}
else {
newvalueMonth = valueMonth.toString(); //Convert to string
}

var NewYYMM = LastTwoYearChar + newvalueMonth; //Combine both month and year
        //Eg. Year 2012 month 9

return NewYYMM; //Answer 1209
}

The reason why im doing this because it is needed for auto numbering year format. Requested in other way.