Dynamically editing ticket text

Moderator: crythias

Locked
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Dynamically editing ticket text

Post by aph »

How can I dynamically add text to rich text editor when creating tickets. I'm trying to achieve something similar to this
viewtopic.php?f=62&t=5157#p23375
I slightly changed the function (removed the argument Queue):

Code: Select all

function toChange() {
   var oEditor = FCKeditorAPI.GetInstance('RichText');
   }
The switch is as follows

Code: Select all

$('#Dest').bind('change', function (Event) {
                Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
            switch ( $('#Dest').val() ) {
                    case "5\|\|xxxx": 
                        			oEditor.SetHTML('this is line one<br/>and line2');
						break;
						.....
						}
My idea is to insert text to the RT editor whenever a certain value is selected for queue or a dynamic field for that matter. How do I achieve this?
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Dynamically editing ticket text

Post by crythias »

OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

I used the following statement:

Code: Select all

document.compose.RichText.value = "Employee Name: \nPosition: ";
instead of:

Code: Select all

oEditor.SetHTML('this is line one<br/>and line2');
Yet the text is not inserted in the body. Am I using the correct statement. The entries in post you referred to use the document.compose.RichText.value statement. Am I missing something? My code snippet below

Code: Select all

$('#Dest').bind('change', function (Event) {
                Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
            switch ( $('#Dest').val() ) {
                    case "5\|\|xxxx":
                                 document.compose.RichText.value = "Employee Name: \nPosition: ";
                  break;
                  .....
                  }
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Dynamically editing ticket text

Post by crythias »

You might want to alert something and try it without on switch to make sure it works at all.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

I didn't quite get you, but the switch is working fine. The alert pops up when the relevant queue is selected. I'm also able to show/hide fields dependant on the queue.

When I place the document.compose.RichText.value = "xxxx" statement outside the switch, it works and the value is inserted in the richtext box. Wonder why it doesn't work within the switch
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

I also tried removing other statements from the switch to see whether they are any way blocking the statement from being excecuted, yet no success
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

Any ideas on this? I have attached the entire .dtl. Below is my script

Code: Select all

            function queueFields() {
            $("[id^=DynamicField]").parent().addClass( 'Hidden' );
            $("[id^=LabelDynamicField]").parent().addClass('Hidden');
        }
            $('#Dest').bind('change', function (Event) {
                Core.AJAX.FormUpdate($('#NewEmailTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
            switch ( $('#Dest').val() ) {
                    case "5\|\|ABC": // need to slash escape the pipes. Also, need to be in numerical order
                        queueFields();
						document.compose.RichText.value = "Dept: ABC <br>Position: ";

                    break;
					
					case "6\|\|PQR": // need to slash escape the pipes. Also, need to be in numerical order
                        queueFields();
						document.compose.RichText.value = "Dept: PQR <br>Position: ";
                        
                    break;
                    default:
                        queueFields();

                }
            });
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

I came a step further. I was able to insert text using a statement inside the switch.

Code: Select all

document.compose.Subject.value = "test ";
On selecting the queue, the text is inserted in the subject field. I simply cannot figure out why the document.compose.RichText.value = "Dept: ABC <br>Position: "; statement doesn't work from within the switch.

Any pointers on this?
Last edited by aph on 04 Dec 2014, 14:09, edited 1 time in total.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Dynamically editing ticket text

Post by reneeb »

Code: Select all

 CKEDITOR.instances.RichText.setData("test");
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Dynamically editing ticket text

Post by aph »

That did it. Thanks!
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
Locked