わかりました私はそれを解決しました。
crm では、javascript コードを統合して aspx サイトを開きました。
function CreateVCF()
{
var entityName = Xrm.Page.data.entity.getEntityName();
var guid = Xrm.Page.data.entity.getId();
window.open("http://xxxxx/vcfexport.aspx?guid="+guid+ "&name="+entityName );
}
そこで、vcard を作成し、それをダウンロードに戻します
public partial class vcfexport : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
//Authenticate using credentials of iis
ClientCredentials Credentials = new ClientCredentials();
Uri OrganizationUri = new Uri("http://server/org/XRMServices/2011/Organization.svc");
Uri HomeRealmUri = null;
OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null);
IOrganizationService service = (IOrganizationService)serviceProxy;
String guidString = Request.QueryString["guid"];
String entityName = Request.QueryString["name"];
if (guidString != null && entityName != null && guidString != "" && entityName != "") {
ColumnSet columnSet = new ColumnSet(true);
Guid guid = new Guid(guidString);
// retrieve the contact dataset
Entity contactEntity = service.Retrieve(entityName, guid, columnSet);
// create new vcard
VCard vcard = new VCard();
vcard.FirstName = contactEntity.GetAttributeValue<String>("firstname");
vcard.LastName = contactEntity.GetAttributeValue<String>("lastname");
//......
String fileName = vcard.LastName + " " + vcard.FirstName + ".vcf";
Response.ContentType = "text/x-vcard";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
// give download window
Response.Write(vcard.ToString());
Response.End();
} else {
lblError.Text = "Es ist ein Fehler aufgetreten. Entityname oder guid sind falsch";
}
}