cancel
Showing results for 
Search instead for 
Did you mean: 

Validating a Field (Actual End Date) in Schedule Item Class of Master Agreement

Former Member
0 Kudos

Hi!

I've been trying to create a validation script for the actual end date on master agreement, depending of some business logic I would be able to let the user add a new end date, or leave the space blank.

The problem I'm having is that the script is not being called to verify the validation.

I did a quick test, to not allow the user to change (or add data) to the field, and it's letting me do so.

What I did in the script was this:

throw doc.createApplicationException(field.getAttributeId(),"Validation is Working!.");

Do I have to try it different because i'm handling a Date Field, or how could i achieve this validation?

Thanks a lot in advance 🙂

Accepted Solutions (1)

Accepted Solutions (1)

kushagra_agrawal
Active Participant
0 Kudos

Hi Oscar,

Could you please elaborate the requirement.

Thanks,

kushagra A

Former Member
0 Kudos

Hi Kushagra!

Thanks for answering.

Could you please tell me what do you mean by requirement?

I'm not completely sure of what you're asking.

Is it a bigger explanation of what I'm doing?

If so:

-I'm creating a Script, of data validation.

-I'm selecting the class of Schedule Item

-I'm selecting the "ACTUAL_END_DATE" field as a target.

The script is not running, or the script I'm using is not working for the specific kind of field (I have a feeling of this because, I've never validated a Date field).

First I did the whole script with the logic and it didn't work, then I deleted everything and only left the following line:

throw doc.createApplicationException(field.getAttributeId(),"Validation is Working");

I did this in order to test if the script was being called, but it let me edit it anyways.

The script isn't inactive or so, so I'm not sure what could be going on.

What I'm asking is if anyone has ever done a DateField validation, and if so, how did they make it work.

Thanks in advance!

kushagra_agrawal
Active Participant
0 Kudos

Hi Oscar,

As per my understanding from the above explanation. You want to fetch the actual end date and do the validation. Correct me if I am wrong.

From the below line of code you can get the actual end date which is being set in the field ACTUAL_END_DATE

scheduledCollection=doc.getSchedItems();

Iterator itr = scheduledCollection.iterator();

while(itr.hasNext())

  {

  member=itr.next();

  actualEndDate=member.getActualEnd().getDate();

  throw new ApplicationException("actualEndDate"+actualEndDate); // it will throw the field value

  }

After getting the value you can do the validation or whatever logic you want to write.

Please let me know if you need more clarification.

Let me know if it helps.

Thanks,

Kushagra A

Former Member
0 Kudos

Hi Kushagra.

Thanks for answering.

I'm gonna try and give you the entire context in order for you to understand what's the problem I'm having:

In the Master Agreement Schedule Tasks, we added an extension in order to handle Corrective Actions on those tasks.

The main purpose of the script I'm writing, is that, the user is not allowed to enter an End Date on the task, if there are still open corrective actions.

I have that logic handled, I use a query to get whenever a task has or hasn't open corrective actions.

The problem I'm having, is that, even when it has corrective actions open, it still let's the user add the date.

Now, what I asume is theroot cause, is that the script is not running whenever I'm trying to add some value into that field. because I did tried with a script that would just send me an email, and it wasn't sent.

as I mentioned before, I did a Validation Field Script, with the Schedule Item, and ACTUAL_END as target.

Here's a screenshot with the description of the script.

I hope that can help you grasp the situation, and sorry for my previous poor explanations.

former_member207877
Active Participant
0 Kudos

Hi Oscar,

You may achieve this using an ONLOAD script instead of FIELD VALIDATION. Below is how I suggest the same.


//ONLOAD SCRIPT
import com.sap.odp.api.doc.IapiDocumentLockManager;

if(corrective_actions){

IapiDocumentLockManager.lockField(session, doc,"ACTUAL_END");

}

else{

IapiDocumentLockManager.unlockField(session, doc,"ACTUAL_END");

}


Hope it helps.

Thanks,

Raj.

Former Member
0 Kudos

Excelent Idea!

What a good way to approach the solution.

Thanks a lot Raj!

Answers (0)