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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Updating fields with Java

(0) ShareShare
ReportReport
Posted on by

Hi all, 

I'm looking at updating a field on one of our custom entities. It's a simple field that I wish to update. Basically the criteria is: 

If field x from contact entity contains data, change field y in our custom entity, from its default, "no" to a yes. 

I have this functioning with a workflow, however in order to see that the field has been updated, you'd need to perform a refresh of the page, which isn't viable for our CS staff. 

Thanks all in advance

*This post is locked for comments

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Hi,

     how is it supposed to work? If you open your custom entity, how and where are you going to change the field on the contact (in other words, at which point would you need to display "yes" in the custom entity form?)

  • Community Member Profile Picture
    on at

    Thanks for your reply Alex.

    Ah, I see. So the minute the contact record is added to the custom entity, and if that contact record has x option set, change the field on the custom entity, from a no, to a yes.

    I hope that explains it a bit more clearly. Additionally I've included a screenshot of the workflow I've created to perform this task.

    http://imgur.com/a/LfIT1

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    You could try writing a Javascript on-load of the form of the custom entity.

    function onLoad() {
        var x = Xrm.Page.getAttribute("xattributename").getValue(); //Get the value of the attribute x
        if (x != null) {
            Xrm.Page.getAttribute("yattributename").setValue(true); // Set the value of the two option attribute y
        }
    }

    Hope this helps.

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    If you are adding a contact through a subgrid, then you might try this:

    - make your workflow a real-time workflow(if it's not)

    - add grid onload event - just refresh data on the form:

    [View:https://msdn.microsoft.com/en-us/library/dn932126.aspx#BKMK_GridControlOnLoadEvent]

    (For the refresh, check this:

    [View:https://msdn.microsoft.com/en-us/library/dn481607.aspx#BKMK_refresh] )

  • ashlega Profile Picture
    34,477 on at

    Actually, you can simply do this:

    - in the grid onload, use gettotalrecordcount to see if there are contact records

    - then set you yes/no field to yes if there are records

    No need to refresh(may still want to keep the workflow if a contact's parent is updated through the contact form)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans