I am using silverlight to create a button that would update a field in CRM 2011
How would I retrieve accountid from [AccountBase] table and then update field in the [AccountBase] table.,
when the user clicks on the account record, is there away to get it's current accountid?
my current code works but I am hard-coding the account id, how do I retrieve the current account id? thank you
private void btnUpdateAccount_Click(object sender, RoutedEventArgs e)
{
Guid _accountid = new Guid("64693B0D-463B-E211-ABBA-000C290C2C64");
Account _account = new Account();
_account.AccountNumber = "121276541";
_account.AccountId = _accountid;
_context.AttachTo("AccountSet", _account);
_context.UpdateObject(_account);
_context.BeginSaveChanges(UpdateAccount, _account);
}
private void UpdateAccount(IAsyncResult result)
{
_context.EndSaveChanges(result);
Account _account = result.AsyncState as Account;
textBoxUpdate.Text = "update end.";
}
*This post is locked for comments
I have the same question (0)If you are using the Silverlight control within your form, you can use the following code within your Silverlight Application:
string accountId = App.Current.Host.InitParams["id"];
Make sure that on the form design, in the properties of the Silverlight control -> Formatting Tab check the "Pass record object-type and unique identifer as parameters".
You can also use the the dynamic object:
dynamic Xrm = (ScriptObject)HtmlPage.Window.GetProperty("Xrm");
var contactid = Xrm.Page.data.entity.getId();
Hope this helps.
Community Member
2
Christoph Pock
1