Help w/Author field

Hello Fellow Developers,

I have searched the forum and can’t seem to find anything specific to help me. I hope that this is not a repeat question. If so guidance in the forum search criteria would be helpful.

I have an action button in a form that creates a record from another form automatically. The problem is that when my record is created, my authors field is not updating correctly.

Here’s the deal, the authors field on this form should be computed based on the status of the record being created. Here’s the formula I’m using:

@If(@Contains(status; “ABC”; “[ABC]”); @Contains(status; “XYZ”; “[XYZ]”); @Contains(status; “123”; “[123]”); “”)

What’s happening is when the record is created, the author field is blank - its not computing. All of the other fields on the form that are computed work fine. The code I’m using that creates these records does include a computewithform so I’m assuming this is why my other computed fields are working correct. It’s only the author field that is not updating when the record is created.

I have figured out that the only way the author field is updated is if I refresh the record. All users will have author access to the database, so of course they are locked out of the record in this state.

I tried changing the author field to an editable field and setting the default value to my formula, same thing occurs. The problem seems to be with computing an @if in the field. I say this because if I put just roles

“[ABC]” : “[XYZ]” : “[123]”

in as either the computed value or in the default value of an editable field, the authors field works fine. I don’t want to use this though because I only want a person with certain role to be able to edit the record.

So any guidance on how can I get my authors field to be automatically updated when the form is created and to be a contain the correct role based on the status of the record would be greatly appreciated.

Thanks in advance!

Subject: Help w/Author field

Fields are evaluated top-left to bottom right, be certain to put this author field below and or to the right of the status field.

Also, make certain that the status field is causing the document to refresh when it changes (Refresh fields on keyword change, or an onchange/onexit event for some fields, combined with run on exit / onchange events after value change)

Subject: RE: Help w/Author field

Hello Peter,

Thank you for the prompt response. The author field is in the correct position (I never knew the order was important so I learned something today) and the status field is a computed field that is set when the record is created. The code to set the field is in the action button I mention along with other fields in the form.

Oh, and I should mention that I set the form properties to automatically refresh fields. I thought this would help when the computewithform kicks in during the creation of the record.

Any other thoughts on why my author field wouldn’t be updating?

Subject: RE: Help w/Author field

Please post your actual formula. What you have posted is not syntactically correct; @Contains takes two arguments.

You might also consider posting your actual code that is creating the document, instead of just telling us it uses ComputeWithForm. What order you do this relative to other things may be important.

There is no problem whatever using @If. There is no situation where you can use a formula, where @If doesn’t work. If what you have said is true, the problem is that the Status field has not yet been assigned a value (or has a value other than the ones you expected) at the time ComputeWithForm is called. The formula for the Status field might also be relevant. Consider changing the Authors field formula to “Status='” + @Implode(Status; ", ") + “'” just to see what result you get (or create another computed field right next to the Authors field with this formula).

Incidentally, I see you are using @Contains to test a value where you probably could use =, which is more efficient. @Contains also works in all formulas, in case you were wondering.

The automatically refresh fields form option does nothing for you here. It’s just an annoyance for the users. Take it out.

Subject: RE: Help w/Author field

Hello Andre,

Your point is well taken about actually posting my code. I should have thought better of posting this way. I do not have access to my code at the moment. I am going to take yours and Peter’s comments into consideration when I’m back in the office. If I still have difficulty, I’ll repost with the actual code I’m using.

Thanks for your time.

Subject: Help w/Author field

Peter & Andre,

Thanks for your advice & guidance.

I now have my authors field properly computing based on the status of the record. I was using the computewithform method to soon in my code.