Events.RecurrenceRule.NewWithFrequency
--------------------------------------

Creates a new recurrence rule.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Events](component_Events.md) | [6.2](newinversion62.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "Events.RecurrenceRule.NewWithFrequency"; Frequency; Interval; EKRecurrenceEnd { ; daysOfTheWeek; daysOfTheMonth; monthsOfTheYear; weeksOfTheYear; daysOfTheYear; setPositions } ) 

**MBS**( **"Events.RecurrenceRule.NewWithFrequency";** /\* Creates a new recurrence rule. \*/  
**$Frequency**; /\* The frequency.  
Can be Yearly, Monthly, Daily or Weekly.e.g. "Weekly" \*/   
**$Interval**; /\* The interval to use.  
Must be &gt; 0e.g. 1 \*/   
**$EKRecurrenceEnd**; /\* The reference to the recurrence end.  
Can be empty.e.g. $RecurrenceEnd \*/   
**$daysOfTheWeek**; /\* Optional; The days of the week list.  
An list of EKRecurrenceDayOfWeek object identifiers. Valid for all recurrence types except daily. Ignored otherwise. Corresponds to the BYDAY value in the iCalendar specification.  
Version 7.1 accepts here also week days, not just RecurrenceDayOfWeek IDs returned from [Events.RecurrenceDayOfWeek.NewWithDayOfWeek](EventsRecurrenceDayOfWeekNewWithDayOfWeek.md). \*/   
**$daysOfTheMonth**; /\* Optional; The days of the month.  
An list of numbers (\[+/-\] 1 to 31). Negative numbers infer counting from the end of the month. For example, -1 means the last day of the month. Valid only for monthly recurrences. Ignored otherwise. Corresponds to the BYMONTHDAY value in the iCalendar specification. \*/   
**$monthsOfTheYear**; /\* Optional; The list of months in the year.  
An list of numbers (1 to 12). Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYMONTH value in the iCalendar specification. \*/   
**$weeksOfTheYear**; /\* Optional; The list of weeks in the year.  
An list of numbers (\[+/1\] 1 to 53). Negative numbers infer counting from the end of the year. For example, -1 means the last week of the year. Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYWEEKNO value in the iCalendar specification. \*/   
**$daysOfTheYear**; /\* Optional; The days of the year.  
An list of numbers (\[+/1\] 1 to 366). Negative numbers infer counting from the end of the year. For example, -1 means the last day of the year. Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYYEARDAY value in the iCalendar specification. \*/   
**$setPositions**) /\* Optional; The list of set positions.  
An list of numbers (\[+/1\] 1 to 366). Used at the end of recurrence computation to filter the list to the positions specified. Negative numbers indicate starting at the end, i.e. -1 indicates taking the last result of the set. Valid when daysOfTheWeek, daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, or daysOfTheYear is passed. Ignored otherwise. Corresponds to the BYSETPOS value in the iCalendar specification. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Frequency | The frequency.   Can be Yearly, Monthly, Daily or Weekly. | "Weekly" |  |
| Interval | The interval to use.   Must be &gt; 0 | 1 |  |
| EKRecurrenceEnd | The reference to the recurrence end.   Can be empty. | $RecurrenceEnd |  |
| daysOfTheWeek | The days of the week list.   An list of EKRecurrenceDayOfWeek object identifiers. Valid for all recurrence types except daily. Ignored otherwise. Corresponds to the BYDAY value in the iCalendar specification.   Version 7.1 accepts here also week days, not just RecurrenceDayOfWeek IDs returned from [Events.RecurrenceDayOfWeek.NewWithDayOfWeek](EventsRecurrenceDayOfWeekNewWithDayOfWeek.md). |  | Optional |
| daysOfTheMonth | The days of the month.   An list of numbers (\[+/-\] 1 to 31). Negative numbers infer counting from the end of the month. For example, -1 means the last day of the month. Valid only for monthly recurrences. Ignored otherwise. Corresponds to the BYMONTHDAY value in the iCalendar specification. |  | Optional |
| monthsOfTheYear | The list of months in the year.   An list of numbers (1 to 12). Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYMONTH value in the iCalendar specification. |  | Optional |
| weeksOfTheYear | The list of weeks in the year.   An list of numbers (\[+/1\] 1 to 53). Negative numbers infer counting from the end of the year. For example, -1 means the last week of the year. Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYWEEKNO value in the iCalendar specification. |  | Optional |
| daysOfTheYear | The days of the year.   An list of numbers (\[+/1\] 1 to 366). Negative numbers infer counting from the end of the year. For example, -1 means the last day of the year. Valid only for yearly recurrences. Ignored otherwise. Corresponds to the BYYEARDAY value in the iCalendar specification. |  | Optional |
| setPositions | The list of set positions.   An list of numbers (\[+/1\] 1 to 366). Used at the end of recurrence computation to filter the list to the positions specified. Negative numbers indicate starting at the end, i.e. -1 indicates taking the last result of the set. Valid when daysOfTheWeek, daysOfTheMonth, monthsOfTheYear, weeksOfTheYear, or daysOfTheYear is passed. Ignored otherwise. Corresponds to the BYSETPOS value in the iCalendar specification. |  | Optional |

### Result

Returns OK or error.

### Description

Creates a new recurrence rule.  
This can be used to build any kind of recurrence rule. But be aware that certain combinations make no sense and will be ignored. For example, if you pass daysOfTheWeek for a daily recurrence, they will be ignored.  
### Examples

Create rule to repeat each year:

 MBS ( "Events.RecurrenceRule.NewWithFrequency"; "Yearly";"1" )  
Create rule to repeat each week:

 MBS ( "Events.RecurrenceRule.NewWithFrequency"; "Weekly";"1"; ""; MBS ( "[Events.RecurrenceDayOfWeek.NewWithDayOfWeek](EventsRecurrenceDayOfWeekNewWithDayOfWeek.md)"; 1) )  
Create event in summer only:

 MBS ( "Events.RecurrenceRule.NewWithFrequency";   
"Monthly"; // by mont  
"1"; // every   
""; // no end date  
"";   
"";   
"4¶5¶6¶7¶8¶9¶10" ) // only this months  
Every week Tuesday and Wednesday:

 MBS ( "Events.RecurrenceRule.NewWithFrequency"; "Weekly";"1"; ""; "3¶4" )  
### See also

- [Events.Item.AddRecurrenceRule](EventsItemAddRecurrenceRule.md)
- [Events.RecurrenceDayOfWeek.NewWithDayOfWeek](EventsRecurrenceDayOfWeekNewWithDayOfWeek.md)
- [Events.RecurrenceEnd.NewWithEndDate](EventsRecurrenceEndNewWithEndDate.md)
- [Events.RecurrenceRule.Frequency](EventsRecurrenceRuleFrequency.md)
- [Events.RecurrenceRule.SetRecurrenceEnd](EventsRecurrenceRuleSetRecurrenceEnd.md)

### Release notes

- **Version 7.2**
    - Fixed bug in [Events.RecurrenceRule.NewWithFrequency](http://www.mbsplugins.eu/EventsRecurrenceRuleNewWithFrequency.shtml).

### Blog Entries

- [MBS FileMaker Plugin, version 7.2pr1](https://www.mbsplugins.de/archive/2017-04-03/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 10th March 2016 , last changed 14th March 2017

  
[Events.RecurrenceRule.MonthsOfTheYear](EventsRecurrenceRuleMonthsOfTheYear.md) - [Events.RecurrenceRule.SetPositions](EventsRecurrenceRuleSetPositions.md)

[HTML Version](EventsRecurrenceRuleNewWithFrequency.shtml)