How to leave 1st If-block and jump into another 2nd if-block after 2 secns

Kishore4321
Tera Contributor

hi All,

We have 5-if blocks 

each If block has 50-lines of code

if(block 1)

{

50 lines

}

if(block 2)

{

50 lines

}

if(block 3)

{

50 lines

}....

..

etc

 

if block 1 would not be executed with in 2-sec, break block 1 loop, directly jump into block2 to execute block 2 code ,
if block 2 would not be executed with in 2-sec, break block 2 loop, directly jump into block 3 to execute block 3 code....etc. like this ... till end.

is this kind of behavior achievable?

 

5 REPLIES 5

Tony Chatfield1
Kilo Patron

Hi, can you clarify your business requirements\drivers for this behavior?
If it was code for a single thread micro-controller then yes it would be understandable, but within the context of ServiceNow I would ensure the design\build did not require this sort of policing/management.

 

We have this type code  behaviour in 3 places

1. service portal widget server code

2. Scheduled job

3. Business rule 

 

Concept : Here each if-block taking huge time to execute , so plan is If code not executed with in defined seconds, we would like to send generic data at final.

 

please let me know if you need any details on this. Let me know does it achievable or not.

 

I tried set interval, set timeout, clear interval but nothing worked.

 

 

 

 

 

 

 

 

 

 

Hi, possibly achievable if your 50 lines of code is some sort of loop, but I think that if it's necessary then you have underlying issues that should be reviewed and resolved, and would not recommend this as a best practice approach for anything ServiceNow related.

I agree this is not best practice.

 

We want to apply that purposefully if it achievable please let me know syntax for it.