;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara

/*
Objective(s)  
- 	This code demonstrates the usage of Variable in Report Scope. 
- 	The Color is being altered based on the variable value. The variable value altered 
	within the Report is undone once the Report is quit. This behavior can be observed 
	by setting the Field to Green color and exittng the Report and reentering the 
	Report. The initial color i.e., Red Background will get restored which shows that 
	the Variable value switches back to default.

*/
    
[Report: Report Scope]

	Form	: Report Scope
	Variable: Report Var        ;;;Defining the variable at the report level

[Form: Report Scope]

	Part	: Report Scope
	Button	: Report Scope Button   ;;;defining button at form level

[Part: Report Scope]

	Lines	: Report Scope

	[Line: Report Scope]
		
		Fields	: Report Scope
	
		[Field: Report Scope]

			Set AS		: $$CurrentDate                                ;;;Will display the current date in the field
			Option		: Report Scope Red BG	: Not ##ReportVar      ;;;Option will execute when conditions is true. Field will appear red
			Option		: Report Scope Green BG	: ##ReportVar          ;;;Option will execute when conditions is true. Field will appear green

			[!Field: Report Scope Red BG]

				Background	: Red
				
			[!Field: Report Scope Green BG]

				Background	: Green

;;Declaration of variable
[Variable: ReportVar]

	Type	: Logical
		
;;Declaring button
[Button: Report Scope Button]

	Key		: Alt + R
    
    ;;On pressing the Key Alt + R, action will trigger to set the variable value
	Action	: Set	: ReportVar	: Not ##ReportVar
    
    ;;Title display on the button will be red or green based on variable value
	Title	: if ##ReportVar then "Red" else "Green"

;; End-of-File
