Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

update field at run time without form

(0) ShareShare
ReportReport
Posted on by

Hi everybody!

I have a doubt about the time of update the field. I have created a jscript to extract the hour time from schedule end  date field to other field, and I prove creating on event onload, onsave and on change. But in all of them, when the record (  the entity is phone call) is created or update by workflow, this field doesn't change/update. This change happens when I open the form. This step is the first to following condition and it doesn't work.

As extracting the hour from date field require code, How do I use this code for working at the moment of change.

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: update field at run time without form

    In that case you can write a plugin which will get the value of schedule and use

    DateTime scheduleDate = record.GetAttributeValue<DateTime>("scheduledend");

    int hours = scheduleDate.Hour;

    Now you can easily set the value of the other field and update the record.

  • JMdeSingular Profile Picture
    JMdeSingular on at
    RE: update field at run time without form

    Hi Vikas and Clément,

    The solution via business rules is great way. But in my case, I don't know how I apply. Maybe I create confusion with fields. I try to explain better.

    The entity is phone call.

    In this entity, there are two fields: Schedule end (date field) and Hour ( whole number field). I create this simple jscript to extract the hour from the date.

    function ShowHour(){

    function muestrahora(){

      var d = Xrm.Page.getAttribute("scheduledend").getValue();

       if (d != null) {

    return   d.getHours()

       }

       else return null;

    }

    var h = Xrm.Page.getAttribute("new_hora").setValue(muestrahora());

    }

    This jscript only run in a form. I need it runs always, like a calculate field.

    I try to make this with business rules  and calculated field but it doesn't have suitable tools to  get attributes of a date field.

    Thanks you both for answer

  • Suggested answer
    BackToTheCrm Profile Picture
    BackToTheCrm on at
    RE: update field at run time without form

    Hello Jose,

    If you are on CRM 2015, you can use Business Rules to set the value of a field from another field value or formula.

    Just set the scope as "Entity" in order to execute this business rule even from outside the UI.

    More info here : technet.microsoft.com/.../dn531086.aspx

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: update field at run time without form

    You can write a business rule to copy the value of date time field and set it to run on server side (by setting its scope to Entity). If you do so, you don't have to write any javascript or workflow. Now what is a schedule here? Is it another entity in CRM or a field on the form only. If its on form you can try if that can be done using business rule too. If not, then you need to write a workflow/plugin. If you want the changes to be applied in real time, you can use a plugin. If timing doesn't matter then you can write workflow.

  • JMdeSingular Profile Picture
    JMdeSingular on at
    RE: update field at run time without form

    Hi Fawad,

    Thanks for answer, I understand it. Would you mind guide me? I made four lines of jscript and when I see workflow code makes me hard. Do you know a tutorial easy to start?

    And What do you recommend? Workflow or plugin?

    Thanks in advance

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: update field at run time without form

    Hi Jose Miguel Cabellos Viana,

     


    when workflow or plugin create an entity this will not touch your webresource. workflow or plugin run on server and your javascript will not run.

    for this you will apply your javascript logic in workflow or plugin.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans