cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic text input on synthetic monitor

Osiris5654
Participant

hello, can we do something like this? In the clickpath section of the synthetic browser Can we dynamically query the PNR number when doing online check-in? For example, we want to take the PNR numbers from file and add them to the field as in the figure.

Mustafa_ERZURUM_0-1687349846415.png

 

I hope I was able to explain. Can I pull the data from a file in the Clickpath section and do this with a script? Thanks.

 

6 REPLIES 6

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

I would say yes if you that file is reachable. It means, if you can make a JavaScript code to reach content in that file, and paste it in that field.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Do you have a sample of the Java Script code I can test?
Regards,
Mustafa.

HannahM
Dynatrace Leader
Dynatrace Leader

How is the file getting updated? Is it another monitor that is creating the booking reference and this one does something with it? If that's the case, you might be better using the Credential Vault. So the first monitor could create the PNR and use the Credential Vault API to update an existing credential, and then the 2nd monitor can just reference it. 

Synthetic SME and community advocate.

Do you have an example?
Regards,
Mustafa.

In the first script, store the PNR value in a Credential Vault entry. CREDENTIALS_VAULT-xxx is the credential vault entry where you are storing the PNR, CREDENTIALS_VAULT-yyy is the token needed to update the crdential vault entry. 

api.startAsyncSyntheticEvent();
var PNR = yourPNRvalue;
url = 'https://yourTenant.live.dynatrace.com/api/v2/credentials/CREDENTIALS_VAULT-xxx';
pdata = '{  "name": "YourCredentialName",  "type": "TOKEN",  "token": "' + PNR + '"}';
api.info(pdata);
fetch(url, {
        method: 'put',
        body: pdata,
        headers: {
            'accept': 'application/json; charset=utf-8',
            'Content-Type': 'application/json; charset=utf-8',
            'Authorization': 'Api-Token ' + api.getCredential("CREDENTIALS_VAULT-yyy", "token")
        }
    }).then(function(res) {
        ResponseCode = res.status;
        api.info("responseCode = " + ResponseCode);
        return res.text();
    })
    .then(function(data) {

        if (ResponseCode == 204) {
            api.finish();

        } else {
            api.fail('Update failed: ' + ResponseCode);
        }
    })
    .catch(e => api.fail(e));

Then in the  second script you can retrieve the PNR and set a variable with it to be used elsewhere in the script

var PNR = api.getCredential("CREDENTIALS_VAULT-xxx", "token");

api.setValue("PNR", PNR);
Synthetic SME and community advocate.

@Osiris5654 did it help you?

When passion meets people magic and innovation happen.

Featured Posts