Win-client, preferences, FieldMandatory, Sale Source

Hello,

My colleague Frode Lillerud discovered a way to set UserPreferences of type "FieldMandatory" through VBScript:


set db = CreateObject("SuperOfficeDB.Database")

isOK = db.login("fl", "fl")
If isOK Then
  db.preferences.set "FieldMandatory", "contact-orgnr", "1"
end if


This works, and makes the Contact OrgNr field show a red underline if it has no value. It also stops the user from saving.

My question is:

- I am trying to do the same for Sale and its Source field, but have no idea what the protocol/identifier is (equivalent to "contact-orgnr", e.g. "sale-source" which doesn't work). Any ideas or tips on where to find information on this? Or, if someone already knows this, please share!

RE: Win-client, preferences, FieldMandatory, Sale Source

I guess you want source_id, "sale-source_id". It is a list in the the GUI named "Source".
sale.source is a field that is not used (yet).

I believe that the protocol is simply tablename-fieldname.

/conrad

Af: Conrad Weyns 12. okt 2017

RE: Win-client, preferences, FieldMandatory, Sale Source

Hi Conrad,

when testing again I see that 'sale-source_id' works, but only partially. I have to edit other fields (not just step out of the source field) to trigger a re-validation of the field.

So, as an example, I've run this:

set db = CreateObject("SuperOfficeDB.Database")
isOK = db.login("fl", "fl")
If isOK Then
  db.preferences.set "FieldMandatory", "sale-source_id", "1"
end if

 

Then start SoCrm.exe (using 8.1.6443.37 aka 8.1 RC2), go to Sale panel, click on "New". Fill in Heading, and then observe that you can't save because Source is mandatory. So far so good. Then I choose a value from the Source dropdown, and click on another field to remove focus from the Source dropdown. Observe that Save is still not enabled.

If I edit, f.ex the Amount field that triggers a re-evaluation, and the Save button becomes enabled. So it seems somewhat buggy :(

Af: Frode Lillerud 12. okt 2017

RE: Win-client, preferences, FieldMandatory, Sale Source

Hi Frode,
What can I say?
To be perfectly honest, I very much doubt that this has been havily tested.
If I am not mistaken, I believe that it requires us to reset the sentry upon every single Set* method in all models and by the same token assure that it will trigger the appropriate GUI event.
I have only seen this explicitly done in a few carefully chosen Set methods.
It has been like this for well over many many years.

All I can do, except for seriously considering my retirement, is register a tfs issue:

54388: Win: Setting a field to mandatory with Sentry-Plugin and/or Poor-man's-sentry-plugin system needs reviewing and testing.

And yes, I suspect both a full fledge Sentry-Plugin and this user preference alternative are affected.

Conrad

Af: Conrad Weyns 12. okt 2017

RE: Win-client, preferences, FieldMandatory, Sale Source

Hi Conrad, as a workaround I think this script will do what we want.

Sub OnCurrentSaleFieldChanged(fieldname)
	if (CurrentSale.Source.Id = 0) then
	  CurrentSale.ValidationMessage = " - Source"
	else
	  CurrentSale.ValidationMessage = ""
	end if
End Sub

The first version of this script included a check to see if the changed fieldname was "sale.SOURCE_ID", but that caused it to not always trigger for new sales. This simpler version seems to work fine, though.

Oh, didn't you get the memo? Your retirement has been cancelled. You're too important, and we need you! Hope to see you at Expander World.

Af: Frode Lillerud 12. okt 2017

RE: Win-client, preferences, FieldMandatory, Sale Source

Yes, the ValidationMessage property will directly trigger a Enable/Disable of the Save button.

Observe that when comparing fieldnames, make sure to be case-insensitive.

Not:

fieldname = sale.SOURCE_ID

But:

StrComp( fieldname, "sale.source_id", vbTextCompare) = 0

I hope you get it to work :-)
Conrad

 

hehe, got the memo now :-)

Af: Conrad Weyns 12. okt 2017