newimport.nrs question

Options
System
System Administrator
I would like to validate fields using an nrs scripts when a user imports a document using filesite 8.5.

What I'm running into is, if the user hits save on the dialog box, I can't stop import process from continuing. Within the newprof.nrs

NewProfileCmd_PostOnOK(pDlg) function, I check the from field (for example)
and if its empty. I added Context.Add "ImanExt.DoOk", false and pDlg.CloseOnOk = false.

However, the import process continues and the newimportcmd_postonok (within newimprt.nrs) gets called.

Any advice on validating fields when the user hits the save button.

Comments

  • Looks like you should be handling it in NewProfileDlg_OnOK(pDlg)
    rather than NewProfileCmd_PostOnOK(pDlg). I believe by the time NewProfileCmd_PostOnOk is called the document has already been imported so its too late to stop it.

    Taken from the WorkSite SDK - iManage WorkSite Dialog Customization Using VB Scripting Developer’s Guide

    Validating the Contents of an Unvalidated Custom Field

    This example validates the contents of an unvalidated Custom field. If the contents of the field are invalid, the CloseOnOK property of the dialog and the iManExt.DoOK context item name value pair are set to false and a message box is displayed indicating that there is a problem with
    the entry. If the contents are valid, the CloseOnOK property of the dialog and the iManExt.DoOK context item name value pair are set to True. This example is for the New Version dialog and should be handled in the NewVers.nrs file.

    ‘ Set the AttributeIDs of the fields being used in the script as
    ‘ constants since enums cannot be used in VB Script
    Const nrCustom17 = 41
    Sub NewVersionDlg_OnOK(dlg)
    ‘ Check to see if the value of the Custom17 field has changed.
    Dim MyCustom17
    MyCustom17=dlg.GetAttributeByID(nrCustom17)
    If MyCustom17 < 25 OR MyCustom17 > 250 then
    ‘ If the value is invalid, display a message and set the CloseOnOK
    ‘ property of the dialog and the iManExt.DoOK ContextItem name
    ‘ value pair to False to prevent the dialog from closing and the
    ‘ OK logic from executing.
    MsgBox "The value entered in Custom17, " & MyCustom17 & ", is _
    out of range. Valid entries are between 25 and 250."
    dlg.CloseOnOK = False
    Context.Add "iManExt.DoOK", False
    Else
    ‘ If the value is valid, reset the CloseOnOK property of the dialog
    ‘ and the iManExt.DoOK ContextItem name value pair to True.
    dlg.CloseOnOK = True
    Context.Add "iManExt.DoOK", True
    End if
    End Sub
  • I have tried activating the following 'Stop Save' lines:
    obj.CloseOnOK = False
    'dlg.CloseOnOK = False 'in Dlg object events
    Context.Add "iManExt.DoOK", False

    In all of:
    NewProfileDlg_OnOK(dlg)
    NewProfileCmd_PreOnOK(obj)
    NewProfileCmd_PostOnOK(obj)

    With no success.

    Interestingly, the Dialog.OnInitDialog and .OnChange events do not seem to trigger until I have clicked on 'Save' in the EAI window - which appears to then be too late to stop the saving of the document if the values fail validation.

    RobCom
  • Looks like I just have to use the FILESAVE.nrs script for EAI mode, not the old NewProf.nrs
TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs