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)

Creating a facility/equipment through c# code with work hours setting var-by-day

(0) ShareShare
ReportReport
Posted on by 605

Hey all 

I was trying to create a facility/equipment and setting its work hours through c# code, i am successfully able to create the facility and set its work hours.

I am able to set the work hours at Freq = Daily/Weekly.

The problem i am facing right now is i am not able to set different timings for different days (Freq = weekly), what is happening is the timings are getting set for all the days in the week and if i change one of the timings all the timings of other days gets changed.

Ex: I set timings like this 

calendarRule1.Attributes["duration"] = 540;

calendarRule1.Attributes["offset"] = 480;

calendarRule1.Attributes["timezonecode"] = 190;

for the calendar rule as shown below:

calendarRule.Attributes["duration"] = 1440; 
calendarRule.Attributes["pattern"] = "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR";

calendarRule.Attributes["timezonecode"] = 190;

The above code adds work hours from Monday to Friday with work hours (8 AM to 5 PM ) 

Can someone assist me with code as to how to set different work hours on different days i.e. Vary-by-day.

 

Thanks in advance

(code snippet is just an example shown - i have all the supporting code added)

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    to set different work hours, you need to go on Users inside administrator, select a user and go on work hourse.  Here you can set different hours for all days and for users.

    Thanks

    Alessandro

  • Rahul G J Profile Picture
    605 on at

    Hi Alessandro,

    Whatever you said was right, it is through the UI that we can do.

    But my concern is, Ihave to do it through C# code. So i need to add the code for setting different timings.

    Suggest me with the c# code.

  • Suggested answer
    Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    maybe this can help you:

    nishantrana.me/.../comment-page-1

    Thanks

    A.G.

  • Rahul G J Profile Picture
    605 on at

    Yes A.G! i have referred it and i needed few tweeks in that code, so i posted the query.

    I able to get it for weekly and daily for same timings all days. But i need weekly settings with different timings on different days.

    For Ex:   Mon (9 AM to 5 PM)

                Tue (10 AM to 12:30 PM)… so on.

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