Setting a text field from a server script

public class MyClass
{
publicstatic BusinessObject1 bo1;
publicstatic Form1 form1;

[Promote(PromotionTargets.ExpressionBuilder)]

[Category("UserCategory")]

   public static string sGetNextInSequence()

    {

    bo1.Refresh();

    string sValue=bo1.NextSequenceFormatted.ToString();
// trying to set the Text1 value
    form1.Fields.Text1.DataValue=sValue;

    return sValue;

    }

}

Its me again.

Via a Button click, I'm trying to return a string from a Business Object (Query) and set the text of a textField with the result.

My server script is above.

 

I'm using a Visual Script Event Handler ( Code Activity to call my server script )

string sReturn = MyClass.sGetNextInSequence();

 Any suggestions ? Am I on the right track - or completrly missing the point ?

 

Tagged:

Comments

  • Looks like mu questions boils down to:

     

    How do I set a text field in a server script ?

     

    Surely this should be simple - but damend if I can see how to do it :smileymad:

     

     

  • ... and you can tell its Friday afternoon here in UK .... typing getting bad .....

  • You need to pass in an instance of the form's "Local". My form has a local variable called intAge on it:

     

    public static void SetIt(NameOfMyForm.Declarations.Local loc)
    {
    loc.intAge = 21;
    }

     

    ^ is in the server side script.

     

    You call it like this from the form's design surface:

     

    NameOfMyServerSideScriptClass.SetIt(Local);

     

    Make sure the field you are assigning to is also set to be "dependent on another" through its properties.

     

     

  • Hi Tony - not sure what you mean by forms design surface - please explain

     

    Thank you for the prompt reply

  • Aha --- problem solved - all I needed to do was to set the "Field is dependant on another" check box for my text field.

     

    Thanks Tony for pointing me in the right direction .......