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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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.

  • JMdeSingular Profile Picture
    on at

    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

  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Suggested answer
    BackToTheCrm Profile Picture
    on at

    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

  • JMdeSingular Profile Picture
    on at

    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
    Community Member Profile Picture
    on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans