Trying to get a Form in Dialog working.

I’ve got a from showing a list of messages . I want the user to able to click on a REPLY button on one of these records and show a new message in a Form in Dialogue. This should allows the user to create a new message with the details of the message the user is responding to appended to the new message (RE:).

I’ve got the following code that’s not working,

I can’t see where I am going wrong.

var MessageBody = messagebody;
var MessageHeader = messageheader;

application.output(MessageBody);

application.showFormInDialog(forms.SendMessage,200,200,530,550,‘New Message’,true,true,false);
forms.SendMessage.controller.newRecord(true);

application.output(MessageBody);

messageheader = ‘RE’ + MessageHeader;
messagebody = ‘Responding’ + MessageBody;

MerMer

Hi MerMer

Believe the following lines should be before you call the Form in Dialog

forms.SendMessage.controller.newRecord(true);
forms.SendMessage.messageheader = ‘RE’ + MessageHeader;
forms.SendMessage.messagebody = ‘Responding’ + MessageBody;

This will create the new record & populate the fields before you show the new record in the FID.

Regards

Graham Greensall
Worxinfo Ltd

Graham,

Many thanks. It’s a big improvement and nearly working but not quite. For some reason, which I can’t figure, the "RE’ is not being put into the Message Header or MessageBody.

Cheers

MerMer

Sorry, I didn’t spot this earlier - try changing your variable names as they are same as Field Names. Suggest vMessageHeader and vMessageBody for the local variables.

This also makes it easier to understand when looking at the code months later :)

Graham Greensall
Worxinfo Ltd

Graham,

Sound advice, many thanks. Still having a problem though getting the
‘RE’ + vMessageHeader to work and the same with ‘RE’ + vMesageBody. The RE is not being added in along with the local variable.

Cheers

MerMer

What happens in the debugger if you put a break point in after

forms.SendMessage.controller.newRecord(true);
forms.SendMessage.messageheader = ‘RE’ + MessageHeader;
forms.SendMessage.messagebody = ‘Responding’ + MessageBody;

I can’t see why it wouldn’t work however try this:

var vMessageBody = 'Re: ’ + messagebody;
var vMessageHeader = 'Re: ’ + messageheader;

forms.SendMessage.controller.newRecord(true);
forms.SendMessage.messageheader = vMessageHeader;
forms.SendMessage.messagebody = vMessageBody;

This enables you to check the Debugger/Variables window to ensure the vMessage… variables are being set correctly

Graham Greensall
Worxinfo Ltd

Hi MerMer,

Are the fields: messageheader & messagebody display types set as text fields or are they RFT or HTML fields ?

If they are RTF then the data will not be appended as these fields contain hidden tags which format the display text and the appended text falls before these tags and thus remains invisible !

Cheers
Harry

Harry,

Spot on - that must be the reason. They are RTF fields. Is there anyway around this?

MerMer

The method I use for these fields is the following:

// Insert the 'RE:' part in messageheader
elements.nameOfMessageheaderField.caretPosition = 0; // Set cursor position to the beginning of the field
elements.nameOfMessageheaderField.replaceSelectedText('RE:');

// Insert the 'RE:' part in messagebody
elements.nameOfMessagebodyField.caretPosition = 0; // Set cursor position to the beginning of the field
elements.nameOfMessagebodyField.replaceSelectedText('RE:');

Of course you need to name the fields on the form.

Hope this helps.

Can’t take credit for the solution !

Just a combination of a couple of threads over the past week or so which spoke about the vagaries of dealing with these field types plus a ‘Gotcha’ entry on Servoy Magazine by David Workman

Glad that it was resolved though

Cheers
Harry

Just to say, many thanks for the responses and the method which was the work around.

MerMer