cancel
Showing results for 
Search instead for 
Did you mean: 

Uanble the field(file name) only in Approved contract phase to upload the document which is disable in Approved contract phase.

Former Member
0 Kudos

Hi guru's,

I have written a  script targeting:Pre phase change for class:contract document 2002

The purpose of script is to validate if contract document is uploaded in Approved contract phase,if document uploaded move to Signed contract phase.

The script is running fine and even throwing error in Approved contract phase if document is not uploaded and not moving to next phase i.e Signed contract

But the issue we are facing is the field is disable as seen in image in approved contract phase it is available only in Signed contract phase.so we are not able to upload the document in approved contract phase and requirement is Contract document should only be uploaded in Approved contract phase but File name field is only unable in Signed contract phase.

Please sugguest the way how can i unable the filed only in Approved contract phase to upload the document.We tried page customization but no success.

Your inputs are valuable

regards,

Pallavi

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Pavalli,

we are looking into your issue but would need some more explanation to understand the root cause of it.

1) By "But the issue we are facing is the field is disable as seen in image in approved contract phase it is available only in Signed contract phase" Do you mean that the actual field: Final Signed Document is disabled and thus you can't upload a document there ?

Does the Signed Contract phase on your contract document has the external ID "Executed". The system locks all meta data fields after entering field "Executed" and allows the user to upload the final contract image file.

Thanks,

Armin

Former Member
0 Kudos

Hi Armin,

This is the script i have written for Class:Contract Document 2002,Target:Pre phase change

import com.sap.odp.api.common.types.AttachmentIfc;

                import com.sap.odp.api.common.types.LocalizedObjectReferenceIfc;

                import com.sap.odp.api.doc.IapiDocumentLockManager;

                import com.sap.odp.api.ibean.metadata.IBeanFieldMdIfc;

                String CLASS_NAME = "VALIDATION OF ATTACHMENT";

                String ERR_MES = " FILE NOT ATTACHED";

                LocalizedObjectReferenceIfc currentphase = (LocalizedObjectReferenceIfc)doc.getCurrentPhase();

                                //doc.setDocumentDescription("current phase" +currentphase.getDisplayName());

                doc.setDocumentDescription("current phase"+current_phase.toString());

                if ( current_phase.toString().equalsIgnoreCase("Approved Contract"))

                                                {

                                                IBeanFieldMdIfc cont = (IBeanFieldMdIfc)doc.getFieldMetadata("SIGNED_DOC");

                                AttachmentIfc attachClObj  = (AttachmentIfc)cont.get(doc);

                                                                if( attachClObj != null )

                                         {

                                                 

                                                             if( attachClObj.getDisplayName() != null )

                                                               {

                                                                 

                                                                              doc.setDocumentDescription("File Name" + attachClObj.getDisplayName());

                                                                

                                                                }

                                                            else

                                                               {

                                                                                doc.setDocumentDescription("File Name does not exist " );

                                                                                throw doc.createApplicationException(null,CLASS_NAME,ERR_MES);

                                                               }

                                         }

                                      else

                                                {

                                                 

                                                                doc.setDocumentDescription("Attachment does not exist " );

                                                                throw doc.createApplicationException(null,CLASS_NAME,ERR_MES);

                                                }

                                                               

                                }

                                else

                                {

                                                doc.setDocumentDescription("CHECK" +currentphase.getDisplayName());

                }

yes i mean that the actual field Final signed document is disabled in approved contract phase and is available only in Signed contract phase.

Former Member
0 Kudos

Hi Armin,

If you can provide any solution to unable the Final signed contact field in Approved phase do share.

Right now the field is available only in Signed contract phase i want it to be availabe in Approved contract phase so i can upload the document in approved contract phase.

Thanks for your input.

Regards,

pallavi

Former Member
0 Kudos

Hi Pavalli,

per default the contract document has 2 system phases (which are hard coded); the default names are "Draft" and "Executed". I believe the latter is the phase which you call Signed contract phase. You can only upload documents in that phase.

An approach would be to add another phase to your Contract Document (via configurable phase defintion) which is not the default system phase. By doing so, you could still upload contracts in the Signed contract phase.

Hope this helps.

Thanks,

Armin

Former Member
0 Kudos

Hi Armin,

Ya signed contract phase is the executed phase thats correct.

But i believed that phases are defined according to business requirement adding one more phase to a system after executed phase to upload document will be it a good option.????Do tell i am not very much sure on it.

I really appreciate your solution on this.

Moreover can there be any script targeted at:validate and on class:Contract Document2002 to do validation for upload contract document in executed phase.

If you have any information on it please share.

Thanks for your valuable input and time.

regards,

pallavi

Former Member
0 Kudos

Hi Pavalli,

it is my understanding that 2 phases are default phases (Draft and Executed) and only in "Executed" phase the metadata fields in the contract document is locked. Thus only during that phase can the user upload a contract. The user can't create a System phase and Required phase by himself.

So yes, I would recommend creating another phase.

I would need to look at your script in more detail.

Hope this helps for now,

Armin

Former Member
0 Kudos

Hi Armin,

Instead of adding a phase to contract document we are writing a script for

Class:Contract document2002

Traget:Validate

here is the code(import statements are included in actual script)

String CLASS_NAME = "VALIDATION OF ATTACHMENT";

                String ERR_MES = " FILE NOT ATTACHED";

LocalizedObjectReferenceIfc currentphase = (LocalizedObjectReferenceIfc)doc.getCurrentPhase();

                            

     // doc.setDocumentDescription("current phase"+currentphase.getDisplayName());

   if( currentphase.getDisplayName().equalsIgnoreCase("Executed"))

{

   IBeanFieldMdIfc cont = (IBeanFieldMdIfc)doc.getFieldMetadata("SIGNED_DOC");

                     doc.setDocumentDescription(" cont" +cont.getAttributeId());

AttachmentIfc attachClObj  = (AttachmentIfc)cont.get(doc);

                                       if( attachClObj != null )

                                 {

                                                                 

                         if( attachClObj.getDisplayName() != null )

                                         {

                                                                                 

                    doc.setDocumentDescription("File Name" + attachClObj.getDisplayName());

                                                                                

                                                          }

                              else

                                                  {

                  doc.setDocumentDescription("File Name does not exist " );

 

throw doc.createApplicationException(null,CLASS_NAME,ERR_MES);

                                                                                    }

                                 }

                       else

                                      {  

       doc.setDocumentDescription("no attachment existing " );

  throw doc.createApplicationException(null,CLASS_NAME,ERR_MES);

                                         }

}

                           else

                                                {

   doc.setDocumentDescription("CHECK in" +currentphase.getDisplayName());

                                                   }

Please go through the script it checks for uploaded document only on "Executed"phase

But the issue we are facing is that in some phases we are getting null value for current phase in document discription and for some phase we are getiing exact current phase value.

I dont know why this behaviour of script.

can you look into it please.

Regards,

pallavi