I’m trying to use the function system.user.addHoliday in perspective. On a button click it activates the following script:
def runAction(self, event): """ Method that will run whenever the selected event fires. Arguments: self: A reference to the component that is invoking this function. event: An object that holds information about the selected event type """ # Write your script here from java.util import Date try: name = self.getSibling("TextField").props.text date = Date(self.getSibling("DateTimeInput").props.value) date = system.date.format(date,"dd/MM/yyyy") repeat = self.getSibling("Checkbox").props.selected except Exception: response = "Info couldn't be retrieved" try: response = project.pyEightLegsUsers.addHoliday() except Exception: response = "Holiday couldn't be added" self.getSibling("Response").props.text=response
This script utilizes the following code:
def printResponse(responseList): if len(responseList) > 0: for response in responseList: print "", response else: print " None" def addHoliday(): from java.util import Date response = False name = 'adsfasf' date = Date(100,1,1) newHoliday = HolidayModel(name,date,repeat) response = system.user.addHoliday(newHoliday) return infos
The issue that I am having is that whenever I call addHoliday() from the Script Console tool, it successfully adds in the holiday without issues, however when it is called from the button script the second exception is always fired (Holiday could not be added). I am wondering how to fix this?
Thanks for the help,