Hello. 

 

I'm doing an Web services to send a document to sign, the api request the Url of the document so I'm using the following link https:[creatio instance]/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875

 

70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a correspons to the  UId from the SysSchema table where the attachments are stored and the ef68e95e-ef77-eddf-dfa8-685557ee4875 is the Id of the attachment. This URL allows me to dowloand the document to my computer, so I know that is the right link but when I used it in the web service it says that there is no document. 

 

The json of the request is the following 

{
 
    "url_doc": {
 
        "url": "https://151929-crm-bundle.creatio.com/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875",
 
        "name": "Contrato.pdf"
 
    },
 
    "stickers": [
 
        {
 
            "authority": "Vinculada a Correo Electronico por Liga",
 
            "stickerType": "line",
 
            "dataType": "email",
 
            "email":"laura@artica.digital",
 
            "data": "laura@artica.digital",
 
            "imageType": "stroke",
 
            "page": 0,
 
            "rect": {
 
                "lx":74.88173,
 
               "ly":312.32596,
 
               "tx":196.9875,
 
               "ty":373.37885
 
            }
 
        }
 
    ]
 
}

 

When I sent the request the response is 

 

{
    "error": "No document"
}

 

I had try this request with a Dropbox URL and works fine but I need to send the documents that are generated by the Word Reports. That why I'm trying to get the document from Creatio using the URL the API also gives me the option of sending the document using base64 but I dont know how to convert the file easly. 

 

Can you help me please to know what is happenig? 

Thank you

Like 0

Like

4 comments

The reason why this isn't working is because FileService/GetFile requires authentication to read. This is not an anonymous endpoint. The receiver of this, where ever you're sending this URL of the document to, is actually getting a 401 Unauthorized. 

You'd have to either go the route of sending the base64 of the file, or expose an anonymous service in Creatio to provide the file to the other service.

Ryan

Ryan Farley,

Thank you, can you explain me please how can I convert the file to base64 please, I had see some examples but I not sure if I can do it using a script task in a business process or a source code 

Laura Jurado,

The code would look something like this (not tested, but this should get you started). For this, I have two process params, one a uniqueidentifier AccountFileId (an Id of an account file) and second an unlimited text AccountFileBase64. The script task would look something like this:

var fileId = Get<Guid>("AccountFileId");
 
var entity = UserConnection.EntitySchemaManager.GetInstanceByName("AccountFile").CreateEntity(UserConnection);
if (entity.FetchFromDB(fileId))
{
    var base64FileData = Convert.ToBase64String(entity.GetBytesValue("Data"));
    Set("AccountFileBase64", base64FileData);
}

Ryan

Ryan Farley,

Thank you very much. It helped me a lot 

Show all comments

Hello friends and Community, 

 

I am working on PDF Generated QR Code, where I need to include QR Code  that include the Path of the PDF File, but it should be dynamic. for example, for each salary certificate letter, each letter should include the QR Code that shows the URL of that PDF file. 

keep in mind that we did PDF but couldn't able to place a public URL for it. 

 

Any clue,

Like 0

Like

1 comments
Best reply

Hi Ahmad,

I assume that your PDFs are stored in Creatio - keep in mind that the user must be authorized to download them (should be logged into the Creatio application using valid credentials, have an active user session in the app). The system does not have a built-in option to generate QR codes, but this can be achieved in the development process. Then you can add your QR code as an .svg image to an email to send, which can be done in a business process.

If you want any user (not only authorized ones) to be able to download your PDF, you first need to send the PDF to a cloud-based storage service (for example, Google Drive) and then generate a QR code to link to this storage.

Hi Ahmad,

I assume that your PDFs are stored in Creatio - keep in mind that the user must be authorized to download them (should be logged into the Creatio application using valid credentials, have an active user session in the app). The system does not have a built-in option to generate QR codes, but this can be achieved in the development process. Then you can add your QR code as an .svg image to an email to send, which can be done in a business process.

If you want any user (not only authorized ones) to be able to download your PDF, you first need to send the PDF to a cloud-based storage service (for example, Google Drive) and then generate a QR code to link to this storage.

Show all comments

Hi,

 

Is there a way to read data in an edit page url ?

Like 0

Like

5 comments

Hello Thibault,

 

Would you please provide more details on your question, so that we can check it for you?

Hello Yuliya,

 

I am calling a third party service in order to obtain an authorization code from scratch. After that, I am redirected back to my edit page with a code. The url looks like this: https://079046-studio.creatio.com/0/Shell/?code=Uq-EurbsQyJ1si-mXiw_DW7…. I would like to know how I can retrieve the code to put it in a business process.

Hello,

 

Please review this video material, as it may assist you in implementing your task:

https://www.youtube.com/live/mHaGY1DxETw?feature=share&t=292

https://www.youtube.com/live/ehjfcBxpLsQ?feature=share&t=247

Hi, I think you can try this

 

1. Make parameter to record your code, in my example it is simple string parameter called UsrTest2

2. add script task:

 

string resultString = "https://079046-studio.creatio.com/0/Shell/?code=Uq-EurbsQyJ1si-mXiw_DW7…";

string part = resultString.Substring(0, resultString.LastIndexOf('#'));

string newURL = part;

string[] parts = newURL.Split('=');

string itIsCode = parts[parts.Length-1];

Set<string>("UsrTest2", itIsCode);

return true;



 

3. Get some autogenerated page to see the result

4. Result

now my parameter UsrTest2 holds the code from URL. I can use it anywhere in the process now.

 

Note: this example works if your url is going to be static and there will be no extra symbols. If your url format is changed - this code might not work properly. In that case you will have to query the string to find the code after the word "code=", something like this

 

foreach (string queryString in queryStrings)
{
 if (queryString.StartsWith("code="))
	{	
    string codeValue = queryString.Substring("==".Length);
     Console.WriteLine(codeValue);
   }
}

 

Hi, 

 

Thank you for your answer. The URL will not be static since the code will change with every call. However, I am unsure of how to retrieve the URL string.

Show all comments

Hello, 

I have button in mobile application, it's onClick function builds url of our api.

I want to navigate user on that url from onClick handler function, to open browser.

 

How I can navigate user to my url?

Like 0

Like

14 comments

Hello Luka,

 

Please add this function to the module that defines your custom button:

 

execute: function openLink () {

    var appWindow = window.open("https://www.wikipedia.org/","_blank");

    setTimeout( function () {if (!appWindow) {

        appWindow.location ="https://academy.creatio.com/";

            }

            },1000);

}

 

As a result once the button is clicked the function will be executed and in this example the https://www.wikipedia.org/ link will be opened.

 

Best regards,

Oscar

Oscar Dylan,

Is your code fragment for Mobile Application? 

Luka Grdzelishvili,

 

Yes, it was added to the custom module that was then added to the 

CustomSchemas of the mobile application manifest (the button was created using this article https://community.creatio.com/articles/adding-custom-user-action-mobile…) and this function was an example provided in this StackOverflow article https://stackoverflow.com/questions/11710902/can-i-make-a-link-that-wil….

 

Best regards,

Oscar

Oscar Dylan,

Nope, my question is not about opening mobile application from web page.

my question is about, opening web page from mobile application.

Luka Grdzelishvili,

 

Please apply this code, it opens the 

https://www.wikipedia.org/ website upon clicking a custom button inside the mobile app.

 

Best regards,

Oscar

Mark as 'Best reply'

Oscar Dylan,

This solution is not working, as I already said it is for Web Browser. When I start test tool for application, it runs using chrome and window.open works, but in android application, it has error. 

I have this fragment in my execute function

var winPrint = window.open("", "_blank");
winPrint.document.write(response.value.data.agreementText);
winPrint.document.close();

 

I saw error log, and there is problem at winPrint.document.write, Cannot read property 'write' of undefined.

 

I tried var winPrint = window.open("https://google.com", "_blank"); and it works. Now I have what is that view? and how can I set HTML content.

 

My api returns HTML string. I wrote question about url because I thought it was impossible to open web view from JS execute function.

It works, thanks

I have another problem now.

I need to print opened document, but there is error winPrint.print is not a function.

Can I somehow print opened page ?

Hi Luka,

 

Could you please specify where you are trying to write your code? Is this related to the mobile app needs described above or you want to implement another feature? What is your business task? Could you please also clarify what schema you use and provide a full code so we will be able to test it at our end? 

 

Regards,

Anastasiia

Anastasiia Markina,

Hello,

My business task is:

  1. add button to get General Agreement (we have Html format at our API, if needed we can return URL)
  2. after successful response, take returned html (or url) and show document to user
  3. show print preview to print document.

In web, we have small JS code to handle it.

// url parameter is empty because we are writing html in document.
// also we can generate blob url and set it without writing directly in document
var winPrint = window.open("", "", "left=0,top=0,width=800,height=600,toolbar=0,scrollbars=0,status=0");
winPrint.document.write(response.value.data.agreementText);
winPrint.document.close();
 
setTimeout(function() {
    winPrint.print();
}, 1000);

On mobile app, I tried to generate blob url and code fragment is 

var blobUrl = URL.createObjectURL(
    new Blob([response.value.data.agreementText], { type: "text/html" })
);
var winPrint = window.open(blobUrl);
 
setTimeout(function() {
    winPrint.print();
}, 1000);

this code, opens webview and shows my html, but print function is not defined, beacuse winPrint doesn't owns it.

 

After it, I tried another way, added new field and set blobUrl as its value. new field type is link, so user must click on it. but second problem appeared, Terrasoft.Utils library has metod getUrl as I remember, which is calling on click, this method validates url, but in this case it makes url invalid. blob url is "blob:file:///..." and this method prepends http:// and because of it blob url is invalid. 



But now I have new workaround, upload pdf on storage, return storage url from API, set it to new field and click on it.



But if print function is implemented and needs specific usage I want to know it. It is not good to upload temp files on storage :( 

Hi Luka,

 

Could you please provide a step-by-step description of your business task? Alas, it is still a bit unclear. 

 

Could you please describe where the button should be located? What section from the left-panel list (menu) should I open? Could you please do it in a way like "go to Cases section > open a case > choose such-and-such field/button > it opens the web-page we need"? The link is the HTML from your API, am I correct? 

 

As for the third point ("show a print preview to print document"), could you please specify how you want to print it? The user opens the General Agreement by clicking the newly-created custom button, then see the Agreement itself in the HTML format and how it will be printed? Will a user be asked to print it (like an alert notification)? Are you going to print it through a usual wireless printer machine like an average hard-printed paper? 

 

Looking forward to hearing from you!

 

Regards,

Anastasiia

Anastasiia Markina,

Hello,

First of all, I already done this task, using business rule, setting API url in custom field and then user must click on it. It opens chrome and our API will show html content and calls print preview in chrome.

 

Yes, We want to print document using wireless printer, using chrome print preview.

 

Here is task:

- Go to contacts -> Select contact -> Open actions -> Click Print General Agreement button.

 

Button action:

  1. Send API request
  2. Read html content of general agreement from response
  3. Show this html content as web page
  4. Initiate print preview

To achieve this, I tried:

  1. Open new window using window.open and set document content from api response. this case was failed, because opened window object hasn't Print function to print document, because opened window object isn't fully same as base window object.
  2. Tried to create Blob url using native js functionality, I got link, set it to my custom field value, but on click, bpm utils has function to validate url getUrl and this function cant validate blob url, because it is blob:file:///..... and this function adds http:// from behind.
  3. I made some changes at my api, added new endpoint to return rendered html view. In bpm 'Print general agreement' button makes api request and sets url in custom field value. So user can click on api url, all bpm validations working because url starts with https:// and opens chrome where document is rendered from api.

Luka Grdzelishvili,

 

Let's consider your business task implementation from the very beginning.

 

1. Here is the instruction by the link below on how you can add a button to the mobile app: 

 

https://community.creatio.com/articles/adding-custom-user-action-mobile…

 

2. This code opens a new web-page: 

 

Ext.define("Terrasoft.MyAction", {
    extend: "Terrasoft.ActionBase",
 
    config: {
        useMask: false,
        title: "MyActionTitle",
        iconCls: Terrasoft.ActionIcons.Copy
    },
 
    execute: function(record) {
        this.callParent(arguments);
        var appWindow = window.open("https://www.wikipedia.org/", "_blank");
		setTimeout(function() {
  		if (!appWindow) {
    		appWindow.location = "https://academy.creatio.com/";
  		}
		}, 1000);
    	}
});

Please do not forget to add a local string as the instructions state, restart the application pool, and re-login to the mobile app. 

 

All these steps described above create a working button and open a web-page (it works correctly at both our end and yours). 

 

Thus, as the main part is implemented and works well, please double-check your API and printer settings. Alas, this point is not our expertise and could not be considered within Creatio development tools. 

 

Regards,

Anastasiia

Anastasiia Markina,

Thanks for very detailed answer. 

 

But, my business task isn't only this what you describe. After opening window with my location, I want to initiate print() function of window object, but it hasn't implemented because opened window object is not same as in chrome or other browser.

 

As I mentioned, I Already done this task, with small workaround. After clicking button, which brings url from API, I set that url to my custom field (viewType: url) . So user click that field and it opens chrome or other browser, and there I can use print() function.

Show all comments

When drilling into a detail record from an edit page, the URL shown for the page in the address bar does not update to match the record shown by default. Is there any way to make this happen in client-side code? Or perhaps a setting which can be enabled? An important part of the application I'm currently working on is the ability for users to share the links to pages externally, and being able to do so by copying the URL sometimes (e.g. when drilling into a Section record to get to the edit page) but not other times isn't good UX for the client.

 

We know we can add an action bar button to copy the link, but this also isn't what he client would like if avoidable, for the above reason (consistency).

Like 0

Like

1 comments

Hello Harvey,

 

Unfortunately, there is no way to retrieve a direct URL when opening a record from the detail since Creatio is a single-page application, the navigation is stored in operative memory and could not be obtained. This is done to enhance system speed.

 

We do have a problem registered for our R&D team in the "Accepted" status regarding the possibility to dynamically change the link once the record from the detail is opened and it is planned to modify the current logic in one of the future releases. As for now the only way to retrieve the direct link is to open the detail record in another tab by right-clicking on it and selecting the "Open in another tab" option.

 

Best regards,

Oscar

Show all comments