# Set a Field using the Execute Custom Code with a BPM
**Category:** [Epicor ERP 10](https://www.epiusers.help/c/e10/5)
**Created:** 2016-09-23 19:02 UTC
**Views:** 6186
**Replies:** 1
**URL:** https://www.epiusers.help/t/set-a-field-using-the-execute-custom-code-with-a-bpm/35530
---
## Post #1 by @DurangoBurke
I know about the Set Field setter within a BPM, but I need to set a field based on the return value of a custom routine.
My thought was that I'd use the "Execute Custom Code" caller to try and perform this task. So I pasted the following code and I updated the Usings tab, but I get the "There is at least one compilation error." message upon save.
I have no idea if my syntax is correct or if this is even doable and I'm struggling to try and find any documentation?
public static int GetWeekNumber(DateTime dtPassed)
{
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
return weekNum;
}
int intWeekNumber = GetWeekNumber(ttJobAsmbl.ReqDate_c);
ttJobAsmbl.Week_c = intWeekNumber;
---
## Post #2 by @rbucek
David,
Because of how Epicor encapsulates the code when it builds the BPM you can't jam in a class or function like that. There is a hacky way around it but i dont recomend it for getting functions in because if they change the way they generate the library you're hosed. You can look into using C#[Actions](https://msdn.microsoft.com/en-us/library/018hxwa8(v=vs.110).aspx) as a way to introduce the type of functionality you are. You'll also have to query the temporary dataset using Linq in order to modify the values. There is some BPM documentation on Epic Web regarding this. Your query could look something like this:
```cs
foreach (var ttJobHead_iterator in ttJobHead)
{
Do something here
}
```
or this:
```cs
foreach (var ttJobClosing_iterator in (from ttJobClosing_Row in ttJobClosing
where string.Equals(ttJobClosing_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase)
select ttJobClosing_Row))
{
}
```
There may be some usefull info in the attached.
epicor10_convertedcode_programmingguide_101400.pdf (1.1 MB)
CSharp and ICE3 Cookbook.doc (114.5 KB)
also, helpful if you could post the error details in the future, thanks!
---
**Canonical:** https://www.epiusers.help/t/set-a-field-using-the-execute-custom-code-with-a-bpm/35530
**Original content:** https://www.epiusers.help/t/set-a-field-using-the-execute-custom-code-with-a-bpm/35530