Discussions

 View Only
  • 1.  Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 15:15
    Hello,

    I am building an expense reporting platform that does the following via a button:
    1. Employee hits Submit Expense Report Button
    2. It updates the status to the next status category (this works)
    3. It creates a task in my main ERP app for the next inline to review the expense report (this does not work, it displays the dashboard of this other app)
    4. It should navigate back to the current record in the original app (does not work)

    I can get through #2, and on #3 above it just displays the dashboard of the other app, no new task is created and I dont navigate back to the current app.  here is my code thus far:

    i appreciate in advance the help!

    //Button Styling:
    var text decoration = "text-decoration: none;";
    var text bgColor = "background: #009bce;";
    var text txtColor = "color: white;";
    var text txtAlign = "text-align: center;";
    var text txtShadow = "text-shadow: none;";
    var text border = "border-radius: 5px;";
    var text padding = "padding: 8px 20px;";
    var text display = "display: inline-block;";
    var text font = "font: normal 700 24px/1 'Calibri', sans-serif;";
    var text styleOptns = List("", $decoration, $bgColor, $txtColor, $txtAlign, $txtShadow, $border, $padding, $display, $font);

    //UrlOne: Change Status of current expense report to In Executive Review
    var text URLOne = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Record ID#] &
    [AppToken] &
    "&_fid_6=In Executive Review";

    //URLTwo: Assign a task to Executive Approval in Team Elite App
    var text URLTwo = URLRoot() & "db/bpmv2s5ny" & "?a=API_AddRecord=" &
    "&apptoken=hiddenforsecurity" &
    "&_fid_6=Review Expense Report" &
    "&_fid_8=" & URLEncode(Today()) &
    "&_fid_9=" & URLEncode(WeekdayAdd(Today(),1)) &
    "&_fid_24=Assigned" &
    "&_fid_28=Not Applicable" &
    "&_fid_52=" & URLEncode("iweiss@elitestudioe.com") &
    "&_fid_69=" & URLEncode([Related Team Member]);

    //Display the expense report record
    var text URLThree = URLRoot() & "db/bspk82e7" & "?a=dr&rid=" & [Record ID#];

    //Display the button only if all required receipts are uploaded. Otherwise display error text.
    var bool ReceiptsCheck = If([# of Expense Records over 75 without Receipts]=0,true,false);
    var bool StatusCheck = If([Status]="Not Submitted",true,false);

    If($ReceiptsCheck=false,"Please upload missing receipts",
    If($StatusCheck=true,
    "<div><a style='" & $styleOptns & "' class='Vibrant' href='"
    & $URLOne &
    "&rdr=" & URLEncode($URLTwo) &
    URLEncode("&rdr=" & URLEncode($URLThree))
    & "'>Submit Expense Report</a></div>","Processing Report"))​​

    ------------------------------
    Ivan Weiss
    ------------------------------


  • 2.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 15:23
    Are you sure that submit method work with several  Concat url?  

    Marcelo Benavides Torres 







  • 3.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 15:36
    That is why I posted :)  Cause it is not working so something is wrong in there....

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 4.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 16:05
    Hi. Ok , I'm sorry, I think that you need check the several url in the submit call. 

    Marcelo Benavides Torres 





  • 5.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 16:14
    I could be wrong but I am fairly certain I have that right.  because the app navigates to the home page of the other app.  It just doesnt execute the new record and navigate back to the original app.  I think it has to do with the app switching.

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 6.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 17:43
    On issue is this line needs to be URLEncoded because the text has spaces in it.  Does that fix the problm?

    "&_fid_6=Review Expense Report" &

    "&_fid_6=" & URLEncode(Review Expense Report") &

    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 21:29
    Hi Mark, thanks for jumping in.  That did not fix it.  Same issue.  here is my updated coded with that update and a couple other tweaks I tried:

    //Button Styling:
    var text decoration = "text-decoration: none;";
    var text bgColor = "background: #009bce;";
    var text txtColor = "color: white;";
    var text txtAlign = "text-align: center;";
    var text txtShadow = "text-shadow: none;";
    var text border = "border-radius: 5px;";
    var text padding = "padding: 8px 20px;";
    var text display = "display: inline-block;";
    var text font = "font: normal 700 24px/1 'Calibri', sans-serif;";
    var text styleOptns = List("", $decoration, $bgColor, $txtColor, $txtAlign, $txtShadow, $border, $padding, $display, $font);

    //UrlOne: Change Status of current expense report to In Executive Review
    var text URLOne = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Record ID#] &
    [AppToken] &
    "&_fid_6=" & URLEncode("In Executive Review");

    //URLTwo: Assign a task to Executive Approval in Team Elite App
    var text URLTwo = URLRoot() & "db/bpmv2s5ny" & "?a=API_AddRecord=" &
    "&apptoken=hidden" &
    "&_fid_6=" & URLEncode("Review Expense Report") &
    "&_fid_8=" & URLEncode(Today()) &
    "&_fid_9=" & URLEncode(WeekdayAdd(Today(),1)) &
    "&_fid_24=Assigned" &
    "&_fid_28=" & URLEncode("Not Applicable") &
    "&_fid_52=" & URLEncode("iweiss@elitestudioe.com") &
    "&_fid_69=" & URLEncode([Related Team Member]);

    //Display the expense report record
    var text URLThree = URLRoot() & "db/bspk82e7" & "?a=dr&rid=" & [Record ID#];

    //Combine the URL
    var text URLCombined = $URLOne &
    "&rdr=" & URLEncode($URLTwo) &
    URLEncode("&rdr=" & URLEncode($URLThree));

    //Check if the receipts required are uploaded
    var bool ReceiptsCheck = If([# of Expense Records over 75 without Receipts]=0,true,false);
    //Check if I am in the correct status for the button to appear
    var bool StatusCheck = If([Status]="Not Submitted",true,false);

    //Display the button only if all required receipts are uploaded. Otherwise display error text.
    If($ReceiptsCheck=false,"Please upload missing receipts",
    If($StatusCheck=true,
    "<div><a style='" & $styleOptns & "' class='Vibrant' href='" &
    $URLCombined &
    "'>Submit Expense Report</a></div>","Processing Report"))

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 8.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-21-2022 22:08
    Good evening. 

    Delete the "=" symbol after  api_addrecord 

    a=API_AddRecord=" 

    Marcelo Benavides Torres 







  • 9.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-22-2022 07:30
    That did it!  Spent hours on this and missed that dumb= lol. Thanks so much!

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 10.  RE: Struggling with Formula API that edits records in two apps

    Posted 09-22-2022 07:38
    Good morning. 

    I understand , after 24 years of coding things like this still happen to me.

    An old boss taught me that you had to rest your mind and then solve.

    Have a good day.

    Marcelo Benavides Torres