Monday 30 September 2013

DQL to create and run documentum job

create dm_method object set object_name='UtilityMethod', set run_as_server=1, set use_method_server=1, set method_type='java', set method_verb='com.myproj.methods.MethodUtility';


create dm_job object set object_name='UtilityJob', set method_name='UtilityMethod', set method_arguments='-folder_path /ABC/folder1/folder2', set start_date=date(now), set expiration_date=date('27/07/2014','dd/mm/yyyy'), set run_interval=1, set run_mode=2, set pass_standard_Arguments=1

----------------------------------------------------------------
To run a job you can use DA administration/job management/jobs.
or
execue the method directly using DQL query as below.

EXECUTE do_method WITH method = 'UtilityMethod', arguments = '-user_name dmadmin -docbase_name Repository_name -folder_path /ABC/folder1/folder2';

Pass custom arguments in your job

If you want to pass custom arguments along with default one, you should write a code to fetch them manually.

In below piece of code we are passing -folder_path "/Cabinet/Folder1/Folder2" as custom argument.

-------------------------------------------------------------------------------------------
public class TestJobMethod implements IDmMethod{
                public void execute(Map arg0, OutputStream arg1) throws Exception {
      
        IDfSession session = getSession(arg0);
        IDfSysObject oIDfJob = null;
        oIDfJob = (IDfSysObject)session.getObject(new DfId("job id"));
        for (int i = 0; i < oIDfJob.getValueCount("method_arguments"); i++) {  
            String strArgument = oIDfJob.getRepeatingString("method_arguments", i);  
            if (strArgument.indexOf(" ") > 0) {  
                String strKey = strArgument.substring(0, strArgument.indexOf(" ")).trim();  
                String strValue = strArgument.substring(strArgument.indexOf(" ") + 1).trim();  
          
                if (strKey.equalsIgnoreCase("-folder_path")) {  
                                 DfLogger.warn(this, "Key: " + strKey + " value: " + strValue, null, null);
                    // Handle parameter  
                } 
            }  
        }  
      
                }
                private IDfSession getSession(Map map) {
        String userName[] = (String[]) map.get("user_name");
        String docbase[] = (String[]) map.get("docbase_name");
      
        IDfSession session = null;
        IDfClientX clientX = new DfClientX();
        IDfClient client;
        IDfLoginInfo loginInfo = new DfLoginInfo();
        loginInfo.setUser(userName[0]);
        loginInfo.setPassword("");
        IDfSessionManager sMgr = null;
        try {
            client = clientX.getLocalClient();
            sMgr = client.newSessionManager();
            sMgr.setIdentity(docbase[0], loginInfo);
            session = sMgr.getSession(docbase[0]);
        } catch (DfException e) {
            e.printStackTrace();
        }
        return session;
    }

}
----------------------------------------------------------------------------------------------


Wednesday 11 September 2013

Captiva Modules

There are few modules which are commonly used in most of the process development. These are basic modules which imports images from various sources like Fax,e-mail,scanner or from any repository. Few of those modules are as follows.

1.     Scan
2.     MDW
3.     Image Enhancement (IE)
4.     Index
5.     Export (Image/Data/ODBC etc)
6.     Multi 

1. Scan: Scanning is importing activity of documents into captiva from scanner. Basically scanning happens at page level to bring images page by page into Captiva.
Scanning is entry point to Captiva where one can import any kind of document like pdf,tiff,jpg etc.
Type of documents depends on business to business but generally .tiff extension is recommended for fast execution of batches in Captiva. One images comes into captive it can go through any modules comes in workflow which will be describe letter in this article.

2. MDW: MDW is another entry point to Captiva. Abbreviation of MDW is Multi Directory Watch which means it’s can be pointed to any folder/repository from where Captiva could import documents directly.MDW is very useful if business is getting documents in form of softcopy for example as attached file in e-mail.MDW also act as Scan module except it does not interlock with Scanner.

3. Image Enhancement: IE is kind of filter or repairing tool for images which are not clear or blur. It enhances image quality so it could be processed easily through captive. One can configure IE as per business requirement and images being received. Main functionality of IE is de-skew, Noise removal etc. Generally IE is used at level 0 which makes it to touch each page of document for corrections.

4. Index: Indexing is data capturing activity in Captiva through which one can capture key data from various field for example if bank form is being processed A/C no and Sort code could be Indexing field. Indexing could be added as per requirement of business. In indexing validation field could be added which avoid unwanted data entry while indexing any document.

5. Export: Export is exit point of Captiva where Images/Data are sent to various repository like File Net,Documentum or data repository. The exported data is used for business requirement for various division of business for example if we are capturing A/C no and Short code for Bank application this could be map to any department where it is needed.

6. Multi: Multi is last process in captive to delete batches which has gone through all over modules and exported value successfully, Multi could be configure as per need of business if it’s required to take backup of  batches this module could be avoided. 

Above mentioned modules are very basic modules of Captiva for Indexing and exporting. But for more flexibility and automation Dispatcher is used which is more accurate to capture the data.

Basic Useful Unix Commands



Tuesday 10 September 2013

JavaScript Date Validation

  Below validation code works for date input of format dd/mm/yyyy or mm/dd/yyyy


function validateDateInput(varDate)
    {
        var flag=0;
        var wrongEntryFlag=0;
        var count=0;
        if((varDate.charAt(1)=='/')||(varDate.charAt(3)=='/')||(varDate.charAt(2)=='/')||(varDate.charAt(5)=='/')||(varDate.charAt(4)=='/'))      
        {
            var checkExpression="0123456789/";
            for(var i=0;i<varDate.length;i++)
            {
                for(var j=0;j<checkExpression.length;j++)
                {
                    flag=0;
                    if((varDate.charAt(i)==checkExpression.charAt(j)))
                    {
                        flag=1;
                        count++;
                    }
                    if(flag==1)
                        break;
                }
            }
        }
            if((count==8 || count==9 || count==10 ))
            {
                return true;
            }
            else
            {
            return false;
            }
    }
 
    function validateDate(varDate)
    {
    if(validateDateInput(varDate))
       {
    var test= new Date();
       var currentMonth = test.getMonth() + 1;
       var currentDay= test.getDate();
       var currentYear = test.getFullYear();
         var varMonth;
           var count;
           var varDay;
           var varYear;
           var count2;

           if(varDate.length==8)
           {
               varMonth=varDate.charAt(0);
               varDay=varDate.charAt(2);
               varYear=varDate.charAt(4)+varDate.charAt(5)+varDate.charAt(6)+varDate.charAt(7);
               }
           else if(varDate.length==10)
           {
               varMonth=varDate.charAt(0)+varDate.charAt(1);
               varDay=varDate.charAt(3)+varDate.charAt(4);
               varYear=varDate.charAt(6)+varDate.charAt(7)+varDate.charAt(8)+varDate.charAt(9);
               }
           else if(varDate.length==9 && varDate.charAt(1)=='/')
           {
               varMonth=varDate.charAt(0);
               varDay=varDate.charAt(2)+varDate.charAt(3);
               varYear=varDate.charAt(5)+varDate.charAt(6)+varDate.charAt(7)+varDate.charAt(8);
               }
           else if(varDate.length==9 && varDate.charAt(2)=='/')
           {
               varMonth=varDate.charAt(0)+varDate.charAt(1);
               varDay=varDate.charAt(3);
               varYear=varDate.charAt(5)+varDate.charAt(6)+varDate.charAt(7)+varDate.charAt(8);
               }
         
         
           if(varYear<currentYear)
           {
               alert("year should be greater than current year");
               document.getElementById("diariseDate_date").value = "Date";
               return false;
               }
           else if(varYear==currentYear && varMonth<currentMonth)
           {
               alert("month cannot be less than current month");
               document.getElementById("diariseDate_date").value = "Date";
               return false;
               }
           else if (varYear==currentYear && varMonth==currentMonth && varDay<currentDay  )
               {
               alert("Date cannot be less than current date");
               document.getElementById("diariseDate_date").value = "Date";
               return false;
               }
           else if (varYear==currentYear && varMonth==currentMonth && varDay==currentDay  )
           {
               alert("date cannot be today's date");
               document.getElementById("diariseDate_date").value = "Date";
               return false;
               }
           else
           {
               return true;
               }
       }
    else
    {
    alert("Not a valid Date value.")
    document.getElementById("diariseDate_date").value = "Date";
    return false;
    }
    }
   

Monday 9 September 2013

Transfer Files from Windows to Unix

Please follow below steps if you want to move a file from window to Unix env.


go to directory from where you want to copy file:
C:\Documents and Settings\myFileFolder>

type ftp and server name to connect to
C:\Documents and Settings\myFileFolder>ftp fx100c1n6

Enter
User (fx100c1n6.ms.com:(none)): test
331 Please specify the password.
Password:test1
230 Login successful.

ftp> put MyFile.class
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 5812 bytes sent in 0.00Seconds 5812000.00Kbytes/sec.

Monday 2 September 2013

Documentum Email Notifications



1      Documentum Events:


Most Documentum email notifications are triggered by events in the repository and correspond to tasks and messages that get queued to a user’s Documentum Inbox. All out-of-the-box Documentum email notifications originate from one of three sources:

  • Jobs (Events like Job_Failure, Agent_Exec_Failure)
  • Registered Events (Events listed in dmi_registry table)
  • Workflow Tasks (All Workflow and router events:)
Below are the events listed which can be considered for notifications:

Event Name
Description
//General repository events:
dm_checkin
Document Checked In
dm_checkout
Document Checked Out
dm_destroy
Document Destroyed/Deleted
dm_fetch
Document fetched/retrieved by particular user session
dm_lock
Document locked
dm_unlock
Document unlocked
dm_branch
Added new branch to the version tree of the document.
dm_prune
Removed a branch from the version tree.
dm_mark
Mark the object
dm_save
Save the object
dm_status
Change the status of document.
dm_link
Link the document to new folder location
dm_unlink
Unlink the document from folder location.
dm_archive
Document archive operation requested.
dm_archive_done
Document archive operation performed.
dm_restore
Restoration requested for object
dm_restore_done
Restoration done for object.
dm_getfile
Document read operation.
//Special events:
Job_Failure
Job failed to execute
Agent_Exec_Failure
agent_exe_method failed to execute
DM_SYSADMIN
Posted event in docbase
//Router events:
dm_end
Terminated the operation
dm_halt
Halted the operation.
//Workflow and router events:
dm_acquire
Acquired the object in workflow task.
dm_force
Forced task to READY state
dm_forward
Forwarded object in a workflow task.
dm_reassign
Reassigned workflow task to new performer.
dm_route
Routed the object
dm_signoff
Signed task
dm_start
Routed the object
dm_reverse
Rejected the object
dm_pause
Paused task
dm_resume
Resumed task
dm_startedworkitem
New workitem started for a workflow instance
dm_selectedworkitem
User selected/acquired particular workitem for processing
dm_completedworkitem
User completed workitem.
dm_pseudocompletedworkitem
Server Completed workitem
dm_reassignedworkitem
User reassigned workitem
dm_delegatedworkitem
User delegated workitem
dm_createworkflow
Created workflow instance
dm_startworkflow
Started workflow instance
dm_terminateworkflow
Terminated workflow instance
dm_abortworkflow
Aborted workflow instance
dm_changestateworkflow
Changed workflow state
dm_changeworkflowsupervisor
Changed workflow supervisor
dm_abortactivity
Aborted workflow activity
dm_autotransactivity
Selected route case for workflow autoactivity.
dm_changestateactivity
Change activity state
dm_changestateprocess
Changed process state

 

2      SMTP Account for Sending Emails


·         By default, Documentum uses SMTP to send email notifications.
·         In order for email notifications to work properly, the Content Server’s installation owner (“dmadmin”) should have a user account with the SMTP server.
·         This is the account specified in the user_address attribute of the dm_user object that has the same user_name as the OS account that installed the Documentum server software.
·          The installation owner’s account will appear in the “From” field of emails sent from the Content Server. In other words, Documentum email notifications will appear to have been sent from the installation owner.
·         If you have configured SMTP server while installation of content server, the value appears in attribute dm_server_config.smtp_server.
Note: This value will be used only if you are using windows –based systems.








3      Unix Platform:


·         Process Flow Chart:

Below flow chart explains how email notification works on Unix based systems.
·         Where to look for email related methods?
File Name
Path on Content Server
Type
dm_html_sender.ebs
/Documentum/product/6.7/bin
ebs Script
dm_event_sender.ebs
/Documentum/product/6.7/bin
ebs Script
dm_mailwrapper.sh
/Documentum/product/6.7/bin
Shell Script
mail
/Documentum/product/6.7/install/external_apps
Docbasic Method
smail
/Documentum/product/6.7/install/external_apps
Docbasic Method

For unix env a shell script command "dm_mailwrapper.sh"(Documentum/product/6.7/bin)will be executed for sending mails.

By default notifications will be sent to owners/ superuserss or in case of workflows group of performers.
Now if you don't want to send notifications to workflow performers but to specifig mail group, you can customize the dm_mailwrapper.sh

/bin/mail -s "$subject" "address" < $content_file

Here in place of address you can put your common group id.

/bin/mail -s "$subject" "my-defined-group@abc.com" < $content_file

4      Disable eMail Notifications:


·         Turn off all e-mail notifications:
If you want to turn off notifications globally for all events, you need update your content server server.ini file at path "$DOCUMENTUM\dba\config\documentum\server.ini" with value mail_notification = F

·         Turn off notifications for some users only:

Update dm_user object and remove the attribute value set for user_address for user you don’t want to send email notification.
UPDATE dm_user OBJECT set user_address = '' where user_name=’$user_name$’;

·         Turn off notifications for some events only:

Update the dm_event_sender.ebs script and do “exit sub” for the events you don’t want to send email notifications.
e.g. Stop mail alerts for dm_startedworkitem event
  Case "dm_startedworkitem"
         exit sub
  object_info_flag = "false"
  task_event_flag = "false"
  router_event_flag = "false"
    subject_line = "Started workitem: " & CleanQuote(package_id) & " in docbase " & CleanQuote(docbase_name)




5      Useful Queries:


·         Changing SMTP Server configuration:

select smtp_server from dm_server_config;

UPDATE dm_server_config OBJECT set smtp_server = ‘<new_smtp_server_name>'

·         To get the method name used for mail notifications:
select method_verb from dm_method where object_name='mail'

·         To get email address set for any user:
select user_address from dm_user where user_name=’$user_name$’;

·         To change event sender method:
UPDATE dm_method OBJECTS SET method_verb = ".dmbasic.exe -f.dm_html_sender.ebs -eMail" WHERE object_name = 'dm_event_sender' 

6      References:


EMC Release Notes for: Email_Notification_Troubleshooting_Guide.pdf

http://www.bluefishgroup.com/2005/configuring-and-customizing-documentum-email-facilities/