Skip to content

Commit

Permalink
Added Refresh and Open buttons for selected record
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Sep 19, 2022
1 parent 134c96c commit 3f38a11
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 44 deletions.
37 changes: 35 additions & 2 deletions XRMTokensRun/XRMTR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ private void Enable(bool on)
{
cmbTable.Enabled = on && Service != null;
btnGetRecord.Enabled = on && cmbTable.SelectedEntity is EntityMetadata;
btnRefresh.Enabled = on && record?.Record != null;
btnOpenRecord.Enabled = on && record?.Record != null;
gbTokens.Enabled = on && record?.Record != null;
btnAddToken.Enabled = on && record?.Record != null && cmbTokenHelp.SelectedItem is TokenHelp;
btnSmartColumn.Enabled = on && record?.Record != null;
Expand Down Expand Up @@ -197,15 +199,33 @@ private void btnGetRecord_Click(object sender, EventArgs e)
Service = Service,
LogicalName = cmbTable.SelectedEntity.LogicalName
};
if (look.ShowDialog() == DialogResult.OK && look.Record != null)
switch (look.ShowDialog())
{
LoadRecord(look.Record.ToEntityReference());
case DialogResult.OK:
if (look.Record != null)
{
LoadRecord(look.Record.ToEntityReference());
}
else
{
record.Record = null;
}
break;

case DialogResult.Abort:
record.Record = null;
break;
}
Enable(true);
}

private void LoadRecord(EntityReference reference)
{
if (reference == null)
{
record.Record = null;
return;
}
WorkAsync(new WorkAsyncInfo
{
Message = "Loading record...",
Expand Down Expand Up @@ -488,5 +508,18 @@ private void btnOpen_Click(object sender, EventArgs e)
txtTokensIn.Text = text;
}
}

private void btnOpenRecord_Click(object sender, EventArgs e)
{
if (Service.GetEntityFormUrl(record?.Record?.ToEntityReference()) is string url && !string.IsNullOrEmpty(url))
{
ConnectionDetail.OpenUrlWithBrowserProfile(new Uri(url));
}
}

private void btnRefresh_Click(object sender, EventArgs e)
{
LoadRecord(record.Record?.ToEntityReference());
}
}
}
107 changes: 71 additions & 36 deletions XRMTokensRun/XRMTR.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f38a11

Please sign in to comment.