web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Custom View not populating Account Field

(0) ShareShare
ReportReport
Posted on by 270

I have a Custom View that was working up until about 3 hours ago.

Based on who the potential Customer is alternate addresses are being pulled and added into a custom view. Note that I couldn't use the PreFilterSearch method because of the complexity of the fetch query.

So I used the method from CRM 2011 that I found which is...

var potentialCustomer = Xrm.Page.getAttribute("customerid").getValue();

if (potentialCustomer != null){

var accountId = potentialCustomer[0].id;

var name = potentialCustomer[0].name;

createViewForBilling(accountId, name);

}

function createViewForBilling(accountid, accountname)

{

var _viewId = '{10CACCF3-AC63-46FE-920B-DFEF53BCDE33}';

var _entityName = 'accounts';

var _viewDisplayName = 'Alternate Bill To Accounts : ' + accountname;

var potentialCustomer = Xrm.Page.getAttribute("customerid").getValue();

var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +

"<entity name='account'>"+

"<attribute name='name' />"+

"<attribute name='primarycontactid' />"+

"<attribute name='telephone1' />"+

"<attribute name='accountid' />"+

"<attribute name='address1_postalcode' />"+

"<attribute name='address1_line1' />"+

"<attribute name='address1_stateorprovince' />"+

"<attribute name='address1_county' />"+

"<attribute name='address1_country' />"+

"<attribute name='address1_city' />"+

"<order attribute='name' descending='false' />" +

"<link-entity name='connection' from='record2id' to='accountid' alias='ah'> " +

"<filter type='and'>"+

"<condition attribute='record2roleid' operator='eq' uiname='Alternate Bill-To' uitype='connectionrole' value='{0F962F93-DDB5-E311-8FAC-6C3BE5A8C238}' />" +

"</filter>"+

"<link-entity name='account' from='accountid' to='record1id' alias='ai'>"+

"<filter type='and'>"+

"<condition attribute='name' operator='like' value='"+accountname+"' />"+

"</filter>"+

"</link-entity>"+

"</link-entity>"+

"</entity>"

"</fetch>";

var layoutXML = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +

                "<row name='result' id='accountid'>" +

                   "<cell name='name' width='250' />" +

                   "<cell name='primarycontactid' width='150' />" +

                   "<cell name='telephone1' width='150' />" +

                   "<cell name='address1_line1' width='200' />" +

"<cell name='address1_city' width='150' />"+

                   "<cell name='address1_stateorprovince' width='100' />" +

                   "<cell name='address1_country' width='150' />" +

"<cell name='address1_county' width='150' />"+

                 "</row>" +

                 "</grid>";

var lookupControl = Xrm.Page.ui.controls.get("new_billto")

lookupControl.addCustomView(_viewId, _entityName, _viewDisplayName, _fetchXml, _layoutXml, true);

The Custom View pulls up properly and gets the right values, but when I select a value and click Add, the Bill To Account field that displays the selected values gets minimized, and then resets to "--" on the next save.

When I use a System View to select an account it works fine.

Any idea why this is happening?

Might it be the fact that the GUID is hard-coded?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    bdmflyer Profile Picture
    270 on at

    *Fixed.

    For anyone who has the same problem... I forgot to get accountid in the fetch.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans