Attachments

Discuss problems installing or using TrackStudio.

Attachments

Postby bodbupnik » Wed Apr 21, 2010 7:58 am

Hi, everybody. I have a question, How can I check in trigger whether user attach a file or not. I need to check it in BEFORE ADD MESSAGE trigger. If there is no one attached file, ask user to do it and don't let the system to finish "Add message" operataion. Sorry, if this question already discussed on the forum. The forum is quite big and I need to solve this as soon as possible/
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Re: Attachments

Postby Petr » Wed Apr 21, 2010 9:14 am

bodbupnik wrote:Hi, everybody. I have a question, How can I check in trigger whether user attach a file or not. I need to check it in BEFORE ADD MESSAGE trigger. If there is no one attached file, ask user to do it and don't let the system to finish "Add message" operataion. Sorry, if this question already discussed on the forum. The forum is quite big and I need to solve this as soon as possible/

Hi. Example for check attached files. Following is code;
Code: Select all
import com.trackstudio.exception.UserException;
if (message.getAttachments().size() <= 0) {
    throw new UserException("You need is add attach!");
}
return message;
TS Support
email: parsentev@yandex.ru
Petr
 
Posts: 1125
Joined: Wed Aug 12, 2009 4:38 pm

Re: Attachments

Postby bodbupnik » Wed Apr 21, 2010 4:45 pm

Petr wrote:
bodbupnik wrote:Hi, everybody. I have a question, How can I check in trigger whether user attach a file or not. I need to check it in BEFORE ADD MESSAGE trigger. If there is no one attached file, ask user to do it and don't let the system to finish "Add message" operataion. Sorry, if this question already discussed on the forum. The forum is quite big and I need to solve this as soon as possible/

Hi. Example for check attached files. Following is code;
Code: Select all
import com.trackstudio.exception.UserException;
if (message.getAttachments().size() <= 0) {
    throw new UserException("You need is add attach!");
}
return message;

Thank's for a quick reply. I test it right now and this script don't let me complete the operation even if I attach a file. I'm not sure but I gues it's because of the attach file is not in database yet when the "BEFORE ADD MESSAGE" trigger works, so this script didn't see it/ Have any idea? Also I checked a little a documentation and didn't saw there a "getAttachments()" method according with message...
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Re: Attachments

Postby Petr » Wed Apr 21, 2010 4:56 pm

Sorry. This script working for TS version 4.
Which version do you use?
TS Support
email: parsentev@yandex.ru
Petr
 
Posts: 1125
Joined: Wed Aug 12, 2009 4:38 pm

Re: Attachments

Postby bodbupnik » Wed Apr 21, 2010 5:03 pm

I forget to write, we use 4.0 TrackStudio right now. Planning to change it on TrackStudio 4.17 soon
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Re: Attachments

Postby Petr » Wed Apr 21, 2010 5:29 pm

bodbupnik wrote:I forget to write, we use 4.0 TrackStudio right now. Planning to change it on TrackStudio 4.17 soon

Ok.
I'm checked this script. all works fine.
I'm did doing on the defaults' datebase.
1. Create file attach.sh. path - /etc/script/before_add_mesage/
2. I'm did go options Workflows -> Bugs -> Operation -> Note -> Trigger
3. I'm chose script - attach.sh
4. I'm added operation "Note". without attach file
5. Get a warning "Add atach files!"
6. I'm added operation "Note". with attach file
7. All right.

Which you have mistake. when run sctipt?

P.S Now we not have documentation about version TS 4
TS Support
email: parsentev@yandex.ru
Petr
 
Posts: 1125
Joined: Wed Aug 12, 2009 4:38 pm

Re: Attachments

Postby bodbupnik » Thu Apr 22, 2010 8:29 am

we have 4 workflows: Error, Report, Task, Question/
I need to set trigger to "Task" workflow, for the "Change Responsible Man" Operation. So I did the next steps
1. Create file try.sh and put it here: /etc/plugins/scripts/before_add_message/
2. Then in TS: Workflows -> Tasks -> Operations -> Change Responsible Man -> Triggers/
3. In the "before trigger" filed I choose script - try.sh and push Save button/
4. Then I create a new "Task" and set Johnsonn as a "Responsible Man" and push Save button/
Offen we have to change responsible man for any reason (for example, Johnsonn have no free time right now and he can't finish the "Task"). And he must find the one who is able to do it and make an operation "Change responsible man" and attach a file with description of reason/
6. So I choose the operation "Change responsible man", fill the name of a new man without attach file, push the Save button and I saw a warning/
7. Then I did again the step #6 with attach file push the Save button and again I see a warning/
I don't have any mistake on a screen, you know. Just warnings which say "You must attach a file". In logs I didn't see any mistakes also. Interesting, the same script but From my side it don't allow me finish the operation even with attach file and from your side, it's working fine.

But if I at first attach any file and only after that make an "Change responsible Man" operation - it's ok. But it's not what we need, because one man can make a lot of such operations and he must every time attach a file/
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Re: Attachments

Postby bodbupnik » Thu Apr 22, 2010 9:32 am

May be there is a "message.hasAttachment()" method in class 'com.trackstudio.secured.SecuredMessageTriggerBean' which return true if user attach a file in CURRENT operation (not in previous)?
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Re: Attachments

Postby Petr » Thu Apr 22, 2010 12:37 pm

bodbupnik wrote:May be there is a "message.hasAttachment()" method in class 'com.trackstudio.secured.SecuredMessageTriggerBean' which return true if user attach a file in CURRENT operation (not in previous)?


Sorry, I'm confused metod getAttachment() and getAtts(). Need use getAtts().
It is exactly the working code.
Code: Select all
import com.trackstudio.exception.UserException;

if (message.getAtts().size() <= 0) {
    throw new UserException("You need is attach file!");
}

return message;
TS Support
email: parsentev@yandex.ru
Petr
 
Posts: 1125
Joined: Wed Aug 12, 2009 4:38 pm

Re: Attachments

Postby bodbupnik » Thu Apr 22, 2010 2:32 pm

Thank you, Petr. It's really working.
Last edited by bodbupnik on Mon Apr 26, 2010 11:43 am, edited 1 time in total.
bodbupnik
 
Posts: 10
Joined: Tue Apr 20, 2010 10:45 am

Next

Return to TrackStudio Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron