Forum Discussion

AleksandarSalap's avatar
AleksandarSalap
Qrew Cadet
8 years ago

Show 'updated by' using API

I created a Webhook to copy all updates of certain fields to new table.
I would also like to have name of the user who changed it. Tried couple of things but couldn't get it to work. Can you please look at my API and point me in the right direction:

<qdbapi>
<udata>mydata</udata>
<usertoken>%user.token.b3p533_s9a_xphg.Aleksandar Johnson%</usertoken>
<apptoken>dzhv6g3d9cdbzkma2jfdjqb57b</apptoken>
<field fid="13">[Record ID#]</field>
<field fid="8">[Product Name]</field>
<field fid="9">[Product Family]</field>
<field fid="10">[Product Release Version]</field>
<field fid="6">[Planned Exit Date (Ideation)]</field>
<field fid="7">[Planned Exit Date (Concept)]</field>
<field fid="11">[Planned Exit Date (Plan)]</field>
<field fid="12">[Planned Exit Date (Dev)]</field>
<field fid="20">%curdate%</field>
<field fid="19">%curuser%</field>
</qdbapi>

I added field 19 and hoping it will record the current user who triggered API, but it always shows my name whoever makes a change. I guess it could be due to the usertoken? I tried wituhout usertoken and it doesn't work.

What should I do to have the name of the user who made the change to those dates?

Thank you!
  • A webhook runs under the authority and persona of the user token, so for all intents and purposes, if it is your usertoken, then it is you.

    The field you want to grab is [Last Modified By]

    That is who actually triggered the Webhook.
  • Thank you very much for the fast reply. That did the job. I thought it would be more complicated than that.
    One side question:
    As you may see, I have 4 dates in that API, even if I change only 1 - I get all 4 copied in new table. 3 are with the same date, 1 with new date. Would I be able and how, to get copied only date that's been changed?
    If I change 2 dates, to get them in new table and other 2 dates to be blank since they were not changed.
    Thanks!
  • You would need to split that up into 4 separate Webhooks.  There is a limit to 10 Webhooks or Actions per table (I presume that the limit of 10 is for the combination of Webhooks and Actions).

    If it wuz me, I would do this with Actions as it appears that you are just doing a an Audit trail and logging date changes into a log table of changes.  Actions are more stupid simple as they are low code / no code.
  • Yup, I figured that out. I created 4 separate Webhooks. Thank you anyway!

    Would I be able to save original date as well? Currently I save only new date but I would like to be able to save original date as well. Could you help me on that?
  • With either a Webhook or an Action yes, it briefly knows the old value in a field just long enough to log.

    here is an example

    You just refer to the "field" as [old.field name] and it will use the old value.  An email Notification actually works the same.  You can use [old.date] to capture what used to be in your field called [date].  That is not a real field, but that notation grabs that old info just long enough to fire off the email notification or Webhook or Action.




    <qdbapi>
    <usertoken>xxxxxxxxxxxxxxxxxxxxxxxxx</usertoken>
    <records_csv>
    %RepeatOn%

    "[Last Modified By]","Client Name","[old.Client Name]", "[Client Name]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Site Name","[old.Site Name]", "[Site Name]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Contact Name","[old.Contact Name]", "[Contact Name]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Contract Name","[old.Contract Name]", "[Contract Name]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Contract Type","[old.Contract Type]", "[Contract Type]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Industry","[old.Industry]", "[Industry]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Primary Project Manager","[old.Primary Project Manager]", "[Primary Project Manager]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Secondary Project Manager","[old.Secondary Project Manager]", "[Secondary Project Manager]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Large Contract Approver","[old.Large Contract Approver]", "[Large Contract Approver]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Estimator","[old.Senior Estimator]", "[Senior Estimator]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Projected Start Date","[old.Projected Start Date (not in use)]", "[Projected Start Date (not in use)]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Projected End Date","[old.Projected End Date (not in use)]", "[Projected End Date (not in use)]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Contact Status","[old.Contract Status]", "[Contract Status]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Award Date","[old.Award Date]", "[Award Date]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Customer PO","[old.Customer PO]", "[Customer PO]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Required Estimate Submission Date","[old.Required Estimate Submission Date]", "[Required Estimate Submission Date]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Revised Estimate Submission Date","[old.Revised Estimate Submission Date]", "[Revised Estimate Submission Date]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Driving Requirements","[old.Driving Requirements]", "[Driving Requirements]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","One Way Miles to Site","[old.One Way Miles to Site]", "[One Way Miles to Site]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","General Contract Notes","[old.General Contract Notes]", "[General Contract Notes]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Specific Location(s) of Work at Client Site","[old.Specific Location(s) of Work at Client Site]", "[Specific Location(s) of Work at Client Site]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Work Being Performed","[old.Work Being Performed]", "[Work Being Performed]", "CO","[Record ID#]","[Record ID#]"

    "[Last Modified By]","Purpose of Work being Performed","[old.Purpose of Work being Performed]", "[Purpose of Work being Performed]", "CO","[Record ID#]","[Record ID#]"  

    "[Last Modified By]","Explanation for change to Required Submission Date","[old.Explanation for change to Required Submission Date]", "[Explanation for change to Required Submission Date]", "CO","[Record ID#]","[Record ID#]"  

    "[Last Modified By]","Specific Location(s) of Work at Client Site","[old.Specific Location(s) of Work at Client Site]", "[Specific Location(s) of Work at Client Site]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Region","[old.Region]", "[Region]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","CCI Breakdown Req'd","[old.CCI Breakdown Req'd]", "[CCI Breakdown Req'd]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Vista Import #","[old.Vista Import #]", "[Vista Import #]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Required Estimate Submission Time","[old.Required Estimate Submission Time]", "[Required Estimate Submission Time]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Special Payment Requirements (if applicable)","[old.Special Payment Requirements (if applicable)]", "[Special Payment Requirements (if applicable)]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Actual Submission Date","[old.Actual Submission Date]", "[Actual Submission Date]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Respectfully, (EF+ From) (userid)","[old.Respectfully, (EF+ From) (userid)]", "[Respectfully, (EF+ From) (userid)]", "CO","[Record ID#]","[Record ID#]" 

    "[Last Modified By]","Date Sent to Customer Frozen by Webhook or URL button on Change Order","[old.Date Locked  by Awarded or Final PDF Created]", "[Date Locked  by Awarded or Final PDF Created]", "CO","[Record ID#]","[Record ID#]" 

    %RepeatOff%
    </records_csv>
    <clist>6.7.8.9.10.11.14</clist>
    </qdbapi>
  • Thank you so much for your continuous and tireless help on any question!
    I made it work, thanks to you.
    Here is the code, it may be helpful to someone, some time

    <qdbapi>
    <udata>mydata</udata>
    <usertoken>%user.token.b3p533_s9a_xphg.Aleksandar Johnson%</usertoken>
    <apptoken>dzhv6g3d9cdbzkma2jfdjqb57b</apptoken>
    <field fid="31">[old.Planned Exit Date (Ideation)]</field>
    <field fid="13">[Record ID#]</field>
    <field fid="8">[Product Name]</field>
    <field fid="9">[Product Family]</field>
    <field fid="10">[Product Release Version]</field>
    <field fid="6">[Planned Exit Date (Ideation)]</field>
    <field fid="20">%curdate%</field>
    <field fid="19">[Last Modified By]</field>
    </qdbapi>