Box Integration

  • 1
  • Question
  • Updated 3 years ago
  • Answered
The following is code based on some suggestions on this community (thanks to all). We are using a custom Object called Service_Type__c and the Model is Service. I get the page to display in a tab, but the authentication error shows and even when putting in my credentials, it fails. Anything stand out?

<iframe src="https://www.box.com/widget_sso/salesforce?

token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_URL_120}}}

%22%2C%22session_id%22%3A%22{{$Api.Session_ID}}%22%7D&

salesforce_object_typed_id={{{$Model.Service.data.0.Id}}}

&partner_object_type=Service_Type__c&partner_object_name={{{$Model.Account.data.0.Id}}}

&partner_object_email=&partner_object_id={{$Param.Id}}

&open_new_window=1&partner_user_id={{{$Model.RunningUser.data.0.Id}}}

&partner_user_name={{$Model.RunningUser.data.0.FirstName}}%20

{{$Model.RunningUser.data.0.LastName}}&partner_user_email={{$Model.RunningUser.data.0.Email}}

&email_recipients=&debug=0"  width="100%" height="800" scrolling="true" id="theIframe"/>

Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Try this instead --- the two $Api merges were incorrect, I fixed them according to the syntax documented here in the Global Merge Variables / functions API docs.

<iframe src="https://www.box.com/widget_sso/salesforce? token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_Urls.12}}}

%22%2C%22session_id%22%3A%22{{{$Api.Session_Id}}}%22%7D&

salesforce_object_typed_id={{{$Model.Service.data.0.Id}}}

&partner_object_type=Service_Type__c&partner_object_name={{{$Model.Account.data.0.Id}}}

&partner_object_email=&partner_object_id={{$Param.Id}}

&open_new_window=1&partner_user_id={{{$Model.RunningUser.data.0.Id}}}

&partner_user_name={{{$Model.RunningUser.data.0.FirstName}}}%20

{{{$Model.RunningUser.data.0.LastName}}}&partner_user_email={{{$Model.RunningUser.data.0.Email}}}

&email_recipients=&debug=0"  width="100%" height="800" scrolling="true" id="theIframe"/>
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Zach,
Thanks but same result with the following code. Changed a bad reference to Model.Account to Model.Service, but no change. I get the authentication page and can't login.

<iframe src="https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_Urls...
%22%2C%22session_id%22%3A%22{{{$Api.Session_ID}}}%22%7D&
salesforce_object_typed_id={{{$Model.Service.data.0.Id}}}
&partner_object_type=Service_Type__c&partner_object_name={{{$Model.Service.data.0.Id}}}
&partner_object_email=&partner_object_id={{$Param.Id}}
&open_new_window=1&partner_user_id={{{$Model.RunningUser.data.0.Id}}}
&partner_user_name={{$Model.RunningUser.data.0.FirstName}}%20
{{$Model.RunningUser.data.0.LastName}}&partner_user_email={{$Model.RunningUser.data.0.Email}}
&email_recipients=&debug=0"  width="100%" height="800" scrolling="true" id="theIframe"/>
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Do you have a running user model?  This line  {{$Model.RunningUser.data.0.Id}}  is looking for information about the current user.  It provides the user information necessary for authentication.  If you don't want to build a model, you could also use global merge syntax to get this information about the user,  rather than creating a model and referring to it.  Look at the document Zach provided for that syntax. 
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
We created a Model called RunningUser and pointed to the User Object, It has 4 fields, ID, First Name, Last Name and Email address. It has a condition of the User records of the User Id is the User Id of the user running this page and alway on. 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Ben, {{{$Api.Session_ID}}}needs to have a lowercase d: {{{$Api.Session_Id}}}

Also, the first part of the URL looks suspect to me: "https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{{{$Api.Partner_Server_Urls...
%22%2C%22session_id%22%3A%22{{{$Api.Session_ID}}}%22%7D 

Maybe it's correct, but would you mind posting where you found this code / iframe embed link?
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Zach, 
Thanks. It is the VF page for the box element:
<apex:page standardController="Service_Type__c">
    <apex:stylesheet value="{!$Resource.box__BoxFilesCSS}" />
    <apex:iframe src="https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{!URLENCODE($Api.Partner_Server_URL_120)}%22%2C%22session_id%22%3A%22{!URLENCODE($Api.Session_ID)}%22%7D&salesforce_object_typed_id={!$CurrentPage.parameters.Id}&partner_object_type=Account&partner_object_name={!URLENCODE(Service_Type__c.name)}&partner_object_email=&partner_object_id={!$CurrentPage.parameters.Id}&open_new_window=1&partner_user_id={!URLENCODE($User.Id)}&partner_user_name={!URLENCODE($User.FirstName)}%20{!URLENCODE($User.LastName)}&partner_user_email={!URLENCODE($User.Email)}&email_recipients=&debug=0"  width="100%" height="800" scrolling="true" id="theIframe"/>
</apex:page>

Just sort of modified what we posted based on comments in the forum.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for posting the code. This is a usually just a big exercize in replacing merge statements. 


After taking apart the query strings here are all the merge statements and the equivalent Skuid Merge statement.  
  • {!URLENCODE($Api.Partner_Server_URL_120)} = {{#urlEncode}}{{$Api.Enterprise_Server_Urls.120}}{{/urlEncode}}

  • {!URLENCODE($Api.Session_ID)} = {{#urlEncode}}{{$Api.Session_Id}}{{/urlEncode}}

  • {!$CurrentPage.parameters.Id} = {{$Param.id}}    (This depends on a URL Param named "id" being passed into the page.)

  • {!URLENCODE(Service_Type__c.name)}  = {{#urlEncode}}{{$Model.ServiceType.data.0.Name}}{{/urlEncode}}  (This depends on a model with the Name "ServiceType" and the field "Name" being present on the page) 

  • {!URLENCODE($User.Id)} = {{#urlEncode}}{{$User.userId}}{{/urlEncode}}

  • {!URLENCODE($User.FirstName)}  = {{#urlEncode}}{{$User.firstName}}{{/urlEncode}}

  • {!URLENCODE($User.LastName)} = {{#urlEncode}}{{$User.lastName}}{{/urlEncode}}

  • {!URLENCODE($User.Email)} = {{#urlEncode}}{{$User.email}}{{/urlEncode}}


After all that replacement,  here is the resulting iFrame code: 

iFrame src="https://www.box.com/widget_sso/salesforce
?token=%7B%22server_url%22%3A%22{{#urlEncode}}{{$Api.Enterprise_Server_Urls.120}}{{/urlEncode}}%22%2C%22session_id%22%3A%22{{#urlEncode}}{{$Api.Session_Id}}{{/urlEncode}}%22%7D
&salesforce_object_typed_id={!$CurrentPage.parameters.Id}
&partner_object_type=Account&partner_object_name={{#urlEncode}}{{$Model.ServiceType.data.0.Name}}{{/urlEncode}}
&partner_object_email=
&partner_object_id={{$Param.id}}
&open_new_window=1
&partner_user_id={{#urlEncode}}{{$User.userId}}{{/urlEncode}}
&partner_user_name={{#urlEncode}}{{$User.firstName}}{{/urlEncode}}%20{{#urlEncode}}{{$User.lastName}}{{/urlEncode}}
&partner_user_email={{#urlEncode}}{{$User.email}}{{/urlEncode}}
&email_recipients=
&debug=0"  
width="100%" height="800" scrolling="true" id="theIframe"


Hopefully this works for you. 

Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Thanks and we have tried this with no luck. We have a Model defined called "Service" and the Name field is called Service__c, under the model which is the "Service" field on the Service_Type__c object (i.e. Service__c). As for the Param.id, not sure where that would be set as box uses the ID of the record it is on to display the folder/files of the related object. 
When this code loads in the skuid UI, we are getting the authentication dialog, so we are not getting past the authentication and so not sure we can even see if the rest of the params are correct. Truly appreciate the effort.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Ok.  Let's debug... 

Go to the rendered page.  Select the BOX.Com section of the page and right click and "Inspect Element" 

Find the iframe code and copy what is there.   Here is a picture from another third party integration. 



I ususally paste the iFrame code into a text editor and compare it with the code I put into the Skuid Template to ensure that all the merge fields are getting correctly the expected data. 

When I see Id's that are mysterious.  I plug them into a salesforce url   ( https://skuid.na3.visual.force.com/PUT_ID_HERE&nbsp;)

This should show you what data is not getting pulled into your Box integration. 
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb

<iframe iframe="" src="https://www.box.com/widget_sso/salesforce

?token=%7B%22server_url%22%3A%22%22%2C%22session_id%22%3A%2200DA0000000HFfX!AREAQO2841zUs7xV3.hbzt469kkmcsSVOB.SGjhnvQjYcosMNJj9NoC95qybEbRIePaQ6joQdTmylfCoE17WDbVKJOOTb2Xo%22%7D

&amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}

&amp;partner_object_type=Account&amp;partner_object_name=

&amp;partner_object_email=

&amp;partner_object_id=a0qF0000006gf3IIAQ

&amp;open_new_window=1

&amp;partner_user_id=005A0000000HnhrIAC

&amp;partner_user_name=Fred%20Flintstone

&amp;partner_user_email=Fred.Flintstone%40bedrock.com

&amp;email_recipients=

&amp;debug=0" width="100%" height="800" scrolling="true" id="theIframe"></iframe>

Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Ooh I see two things. 

1. Look at this line: 
&amp;salesforce_object_typed_id={!$CurrentPage.parameters.Id}
You say above "box uses the ID of the record it is on to display the folder/files of the related object. " 

If you are building a detail page for "Service_Type_c" records,  you probably have a condition on "Service" model that filters down records to one ID.  Usually this is done with a URL parameter.  Whatever this parameter is,  can be re-used here.   If the URL parameter is "Id"  your line needs to read: 
&amp;salesforce_object_typed_id={{$Param.Id}}

2. Look at this line. 

&amp;partner_object_type=Account&amp;partner_object_name=

For whatever reason,  no data is getting populated there.  You said: "We have a Model defined called "Service" and the Name field is called Service__c, under the model which is the "Service" field on the Service_Type__c object (i.e. Service__c)."   If this is the case, the merge syntax needs to be:  "{{$Model.Service.data.0.Service__c}}"  

The rest looks correct. 
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb

One sec, I think I had cached data. Checking again and will post results.

Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb

I did a comparison (sent via email) between what is being rendered and what works in our production environment.

Basically a couple things stand out.

First, the Api.Enterprise_Server_Url.120 is not being set on the Skuid object. 

{!URLENCODE($Api.Partner_Server_URL_120)} is what Box is using in the current VF page and {{$Api.Enterprise_Server_Urls.120}} is what you sent me to use.

Second, the Skuid object is using the 18 digit ID of the object and box using the 15 digit.

Third, I have the object type wrong in Skuid.

Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
{{$Api.Partner_Server_Urls.12}} should be used in Skuid, not {{$Api.Enterprise_Server_Urls.120}} (remove the zero at the end), and use Partner instead of Enterprise.

More than likely the "Skuid object" that you need to pass in to Box is the first row in a Model in your page. Say that the object record is your Service model (I don't know if this is true), then you can get the 15-digit Id of this record by doing this:

&amp;salesforce_object_typed_id={{{$Model.Service.data.0.Id15}}}
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Well after all the input provided, using pieces of each, and much trial and error, we have it working on a custom object. I am going to try and use this same code on another custom object that is a little different and then will send you a pdf of the steps I took and details of how we all got this working, for future reference.
Much appreciated.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
WOOT!  Sorry for the trials and tribulations.  We appreciate your patience. 
Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
Thanks for this post - it has been very helpful. I was able to embed Box within a Skuid tab for the Opportunity object, however, if there is an associated box folder already created it will not show when the tab loads. Instead, it prompts you to create a new folder to associate with the salesforce record.

I'm assuming it has something to do the with folder ID on the box side of things? Does anyone know how to grab an existing salesforce-box folder for a specific record?

Thanks.
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
If your setup is accurate (the setup of the SKUID TEMPLATE), then you should see the associated folder, if one existed already. If you are not seeing the folder then your variables are not correct. For instance, our environment has a root folder of SF, and a specific service object 1209298 has a box folder created with 3 pdf's. The SKUID template needs to be able to read the ID of the object 1209298. If you inspect the page and find the template url, you should see a variable called partner_object_Id= followed by the id (found in the sf url) of the object that has the attachments. If this field is blank, then the variable is not being passed. If the field has a value, then something else is not setup correctly. In the Box "Menu Bar" you should also see the path to at least the root folder, and if not then something else could be wrong as well, but I would guess it is the Object Id.
Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
Hi Ben,

Thank you for the help and quick response! Using your logic to hunt down the issue, I found that changing {{$Param.Id15}} to {{$Model.Opp.data.0.Id15}} (even though the Opp is the param id) allowed the information to flow into the partner_object_Id. I don't understand why, but it worked!

Thanks again.
Chelsea
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
There is probably no parameter in your page with the name "Id15".   There is probaby a parameter of name "Id"  but not "Id15"  The Param call does not pull in model data,  it only pulls in the parameters that have been defined in your page.  The model data merge syntax can access all the data that is in the model. 
Photo of Chelsea Curtis

Chelsea Curtis

  • 1,300 Points 1k badge 2x thumb
Got it. Thanks for the clarification, Rob.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I have this same issue with Box.com inline and this thread has been extremely helpful. I am still stuck, though.
1)The page loads and authentication occurs, but it won't recognize my custom root folder. It creates a new root folder under the default "Salesforce". Where do I indicate that it should look for my custom root folder?
2) Also, the seamless login token does not refresh so I have to log back in after an hour. Is it my code or is there no way to get seamless login to refresh the token?
3) The folder structure doesn't recognize the object name as a folder level. When I use the default Salesforce UI, the folder structure is custom root folder/custom object name/record name. When I use the following code, I get default root folder/custom object name_record name. In addition to not recognizing my custom root folder it is appending the record name onto the custom object name and making them a single folder name instead of having the record name be a subfolder of the custom object name.
I really appreciate your help......

Here is my code:
<iframe src="https://www.box.com/widget_sso/salesforce?token=%7B%22server_url%22%3A%22{{#urlEncode}}{{$Api.Partne...
&partner_object_type=Patient__c
&partner_object_name={{#urlEncode}}Patients/{{$Model.Patient.data.0.Name}}{{/urlEncode}}
&partner_object_id={{{$Model.Patient.data.0.Id15}}}
&open_new_window=1
&partner_user_id={{#urlEncode}}{{$User.userId}}{{/urlEncode}}
&partner_user_name={{#urlEncode}}{{$User.firstName}}{{/urlEncode}}%20{{#urlEncode}}{{$User.lastName}}{{/urlEncode}}
&partner_user_email={{#urlEncode}}{{$User.email}}{{/urlEncode}}
&debug=0"  
width="100%" height="800" scrolling="true" id="theIframe"</iframe>
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
For those of you looking for a solution for box.com, I used this post as a template to create the following code. Replace "Contact" with the name of your object. Add a template component to your Skuid page and paste the code in. Worked like a charm. 

https://community.skuidify.com/skuid/topics/how-to-view-a-visualforce-page-on-a-skuid-detail-page

<html><iframe src="/apex/box__BOXSection?id={{{$Model.Contact.data.0.Id15}}}&param=Contact_Box_Section" width="70%" height="800px" frameborder="false">
</iframe>
</html>