cancel
Showing results for 
Search instead for 
Did you mean: 

MA on save verification script vs MA field validation script

Former Member
0 Kudos

Hi Experts,

I have created one extension field in maser agreement extensions section , to display some text.

The text should display in the new extension field when I duplicate an existing master agreement and saved it.

For this I wrote script and added to existing "MA on save verification script".

The script executes and displays the text in the new extension field on save. But if I reopen the same MA the new extension field is showing empty.

I have added the same code snippet to existing MA field validation script.

It is not displaying the text in the new extension field immediately after duplication and save.

It shows the text only  when I open that MA ,  do some field change and save it.

But I would like to display it immediately on save event.

Can you please guide.

Thanks

Raj

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Raj,

Yes, you are right with the explanation. Can you please check the same script on event "Validated".

you can store the parent MA unique Document name in any string object and then copy the same in the new MA.

String maName= "Master Agreement Name";//can be achieved from scripts

doc.getExtensionField("XYZ").set(maName);

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Thank You for your reply.

I have added the same code snippet in validate event script.As I told in my earlier post, after duplication and save it did not display immediately in the extension field. I has displayed only after reopening the same new MA, doing some changes and save.And it has persisted in the DB.

Why doesn't it display immediately after saving.

To see the parent MA name in the new extension field, we need to reopen the duplicated MA and do some event every time.

Please tell me any alternative...

Thanks

Raj

Former Member
0 Kudos

Hi Raj,

The way you mentioned,it had worked for me earlier.I am not sure but it seems your problem lies in retrieving the parent MA.

Just to add, can you please check with other ways to fetch the parent MA and print it in logs and see whether it is printing correctly as desired without making any changes in the document.

You can use getRootParentIBean() or getParentIBean() to get the parent MA or otherDoc if the script is in duplicated.

Please do print all steps in logs, it will help in debugging.

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Thank You for your reply.

I am able to print parent MA in logs, getting it from fci_link_doc table through DB handle.

Apart from that I tried the methods which you have given.The out put is as follows..

getRootParentIBean() : This method is printing duplicated MA name in the logs. Like "Copy of Test Agreement".

getParentIBean() : This method is giving null in the logs.

I have used these methods in both  duplicate and validate events, I got same result.

Can you please tell me how to handle this..

And what is otherDoc , is this a method ? what is the use of it ? I have seen this in some posts.But I did not find it in IAPI. Can you please explain it.

Thanks

Raj

Former Member
0 Kudos

Hi Raj,

otherDoc is the reference for the document that is being duplicated. The context has to be for Document and event should be Duplicated. In your case it should return the name of The 1st MA.Were you able to print the 1st MA using this variable otherDoc. otherDoc can be used the way you do use doc(for current document).

If you are able to get the name from fci_link_doc table through DB handle then are you able to copy it the extensionfield? Also, you can try the way I have mentioned above using otherDoc.

Regards,

Kumud

Former Member
0 Kudos

Hi Raj,

It appears to me that the script you have written is for event "Saved".

"The text should display in the new extension field when I duplicate an existing master agreement and saved it."

- To achieve this you can write script in duplicate event of MA.

Otherwise, you can also write it for event Validate. This can also fulfil your requirement.

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Thanks for your reply.

First I have tried on Duplicate event but no use.

Later I tried with event validation script.

It is not displaying the text in the new extension field immediately after duplication and save.

It shows the text only  when I open that MA ,  do some field change and save it.

But I would like to display it immediately on save event.

Thanks

Raj

Former Member
0 Kudos

Hi Raj,

Could you please tell me what is the datatype of the extension field. Normally, it should work the way you are saying.

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Datatype of the extension is String.

Thanks

Raj

Former Member
0 Kudos

Hi Raj,

Then it should work. I believe you were able to fetch the parent Master Agreement correctly while writing the script.

The field could be copied from parent MA to duplicated MA using below syntax (at duplicate event).

doc.getExtensionField("XYZ").set(otherDoc.getExtensionField("XYZ").get());

doc= current MA

otherDoc= MA which is duplicated

It should work.

Regards,

Kumud

Former Member
0 Kudos

Hi Kumud,

Thank You for your reply.

When we duplicate one existing MA, in the new MA's document link section we will have it's parent document name from which it has been duplicated.

I am able to fetch the parent MA name from document link section of new MA. I would like to print this parent MA name in the new extension field.

I wrote code in OnSave event. When I duplicate and save, it is displaying the parent MA name.

But when I reopen the duplicated MA, the  extension field is showing empty.

In your post

doc.getExtensionField("XYZ").set(otherDoc.getExtensionField("XYZ").get());

If my understanding is correct, you are trying to set value to the extension field of new MA by getting that value from parent MA's extension.

But parent MA unique doc name is not an extension field, how can we get it with this method..

Please advice.

Thanks

Raj