You should post the script. Otherwise we can't help you find what isn't working.
This is my script
Please carefully compare your script to the examples that I provided.
The date fields must have global storage specified.
Line two of your script should be Enter Find Mode  and you usually would clear the pause check box that is automatically selected when you add this step to your script.
Set Field in line 3 is missing the target field parameter.
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
If [ DateRange::Find_beginning_date]
makes no sense as you do not compare it to a value and you appear to be checking the value of this field only after you use it to perform a find.
When I look at your script in its entirety, it would appear that lines 2, 3 and 4 should be deleted from your script and the first If step needs to have it's expression modified so that it works for the error message (which I can't read) you want to show when this expression is True.
how can i apply it to different layout.
What do you mean by "apply it"?
Will this be a layout based on the same table or a different table?
It's possible to use functions such as Set Field By Name to indirectly refer to a specific field via a table Occurrence::field reference created by a text calculation and it's possible to use the "layout name by calculation" option in go to layout to indirectly refer to layouts.
But the results produced will very much depend on the context established by Tutorial: What are Table Occurrences? specified in "Show Records From" for the specified layout.