Jump to content
Sign in to follow this  
247itsupport

Extradatafield : set value function fails

Recommended Posts

Hi,

I just want to set an EDF to "false" or to "0". However I'm getting an error. The EDF is type "checkbox".

The error is

The Script(482) failed in the Else section at step 1. The reason: SQL Execute failed processing query

Script: S482 - Starting at Server Time: Friday, August 7, 2020 10:15:41 AM
IF F65 Logname(P1):Application   Source(P2):ShadowProtectSvc   EventType(P3): T: 8.2385974
L1 F80 EdfId (P1): 202   TargetId (P2): @computer@   Value (P3): 0 T: 20.3136028

 

Can anybody point me in the correct direction?

Cheers

Capture.PNG

Share this post


Link to post
Share on other sites
Posted (edited)

Use a MySQL REPLACE INTO statement rather than the EDF script functions. The EDF script functions also seem to have a delay before the most recently collected EDF data is actually recognized when EDF data is read from the database (unless you are using MySQL queries to read and write data directly!)

Edited by BlueToast

Share this post


Link to post
Share on other sites

I would also be interested in the recommended MySQL statements to use here; we are on a cloud instance and I am still coming to terms with SQL again after a long break not using it, and remain very cautious about experimenting with any queries that aren't read-only.

Additionally, I was told recently by support, quote, "Extra Data Fields that are displayed under the v_extradatacomputer table are regenerated every 15 minutes." Is that the delay you're referring to, BlueToast? If all one wants to do is set a value and we don't need to call it immediately, that delay wouldn't be much of a concern, no?

Share this post


Link to post
Share on other sites
On 9/4/2020 at 3:19 PM, MetallurgicalMarvel said:

I would also be interested in the recommended MySQL statements to use here; we are on a cloud instance and I am still coming to terms with SQL again after a long break not using it, and remain very cautious about experimenting with any queries that aren't read-only.

Additionally, I was told recently by support, quote, "Extra Data Fields that are displayed under the v_extradatacomputer table are regenerated every 15 minutes." Is that the delay you're referring to, BlueToast? If all one wants to do is set a value and we don't need to call it immediately, that delay wouldn't be much of a concern, no?

If that delay is not a concern, great! If it is, you'll need to resort to MySQL queries to collect data directly from the database on-demand per case.

SELECT a.`Value` FROM extrafielddata a WHERE a.`ID` = '%clientid%' AND a.`ExtraFieldID` = (SELECT b.`ID` FROM extrafield b WHERE b.`Form` = '3' AND b.`Section` = 'Additional Data' AND b.`Name` = 'Enable Software Deployment');
# extrafield.`Form` = 3 is a client EDF, 2 is a site EDF, 1 is a computer EDF. 4, 5, and 7 are other types of EDFs.
# extrafielddata.`ID` = Dependent on whether the EDF is computer, site, or client. In example, if we are looking at a client EDF, the `ID` will be the %clientid%. Location EDF should use %locationid%, and computer EDF should use %computerid%.
# If the result returned in a script is -9999, there are no results returned by the MySQL query

This is a general example to read an EDF. You will have to adjust the values of a.`ID`, b.`Form`, b.`Section`, and b.`Name` on a case by case basis depending on the EDF being sought.

I have not tested the MySQL queries below, use at your own risk:

To write and update (creates row in table if does not already exist, replaces row if duplicate key scenario encountered):

REPLACE INTO extrafielddata VALUES (%clientid%, (SELECT b.`ID` FROM extrafield b WHERE b.`Form` = '3' AND b.`Section` = 'Additional Data' AND b.`Name` = 'Enable Software Deployment'), 1);

To update existing row only:

UPDATE extrafielddata SET Value = 1 WHERE ID = %clientid% AND ExtraFieldID = (SELECT b.`ID` FROM extrafield b WHERE b.`Form` = '3' AND b.`Section` = 'Additional Data' AND b.`Name` = 'Enable Software Deployment');

Long story short: if you are going to go the route of MySQL acquiring gradual familiarity and understanding of the database, its structure, its data, how to write queries, and having a test MySQL database environment (separate from live production). Acquiring this experience and knowledge is a good thing! You will be empowered quite a bit! I did not have very much understanding of MySQL two years ago, but now I have a lot more and exposure to a CWA live production database has provided ample opportunities of seeing something that's real and not synthetic/lab.

I recommend some resources:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...