Docusign dynamic row generation in table - templates

I have to dynamically generate the rows in Docusign template's table. Is there a way to achieve that ? I have to mention customer's detail which can vary from contract to contract and for that i don't want to keep static placeholders for that such that I preconfigure 100 rows and it will populate accordingly.

Your problem will be solved using tab from docusign official docs. Also please read examples here. API ref about envelops will also helps you. Further demonstrations will be following.
function document1(args) {
return (
<div>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>{args.firstName}</td>
<td>{args.lastName}</td>
<td>{args.age}</td>
</tr>
</table>
</div>
);
}
use that document into makeEnvelope function.
function makeEnvelope(args) {
// create the envelope definition
let env = new docusign.EnvelopeDefinition();
env.emailSubject = "Please sign this document set";
// add the documents
let doc1 = new docusign.Document();
let doc1b64 = Buffer.from(document1(args)).toString("base64");
doc1.documentBase64 = doc1b64;
doc1.name = "YOUR markup doc name";
doc1.fileExtension = "html";
doc1.documentId = "1";
// The order in the docs array determines the order in the envelope
env.documents = [doc1];
// create a signer recipient to sign the document, identified by name and email
// We're setting the parameters via the object constructor
let signer1 = docusign.Signer.constructFromObject({
email: args.signerEmail,
name: args.signerName,
recipientId: "1",
routingOrder: "1",
});
// routingOrder (lower means earlier) determines the order of deliveries
// to the recipients. Parallel routing order is supported by using the
// same integer as the order for two or more recipients.
// create a cc recipient to receive a copy of the documents, identified by name and email
// We're setting the parameters via setters
let cc1 = new docusign.CarbonCopy();
cc1.email = args.ccEmail;
cc1.name = args.ccName;
cc1.routingOrder = "2";
cc1.recipientId = "2";
// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings. So the
// signHere2 tab will be used in both document 2 and 3 since they
// use the same anchor string for their "signer 1" tabs.
let signHere1 = docusign.SignHere.constructFromObject({
anchorString: "**signature_1**",
anchorYOffset: "10",
anchorUnits: "pixels",
anchorXOffset: "20",
}),
signHere2 = docusign.SignHere.constructFromObject({
anchorString: "/sn1/",
anchorYOffset: "10",
anchorUnits: "pixels",
anchorXOffset: "20",
});
// Tabs are set per recipient / signer
let signer1Tabs = docusign.Tabs.constructFromObject({
signHereTabs: [signHere1, signHere2],
});
signer1.tabs = signer1Tabs;
// Add the recipients to the envelope object
let recipients = docusign.Recipients.constructFromObject({
signers: [signer1],
carbonCopies: [cc1],
});
env.recipients = recipients;
// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
env.status = args.status;
return env;
}
then make example worker function to use that envelope containing documents(either your table data or something else)
exampleSigningViaEmail.worker = async (args) => {
// Data for this method
// args.basePath
// args.accessToken
// args.accountId
let dsApiClient = new docusign.ApiClient();
dsApiClient.setBasePath(args.basePath);
dsApiClient.addDefaultHeader("Authorization", "Bearer " + args.accessToken);
let envelopesApi = new docusign.EnvelopesApi(dsApiClient),
results = null;
// Step 1. Make the envelope request body
let envelope = makeEnvelope(args.envelopeArgs);
// Step 2. call Envelopes::create API method
// Exceptions will be caught by the calling function
results = await envelopesApi.createEnvelope(args.accountId, {
envelopeDefinition: envelope,
});
let envelopeId = results.envelopeId;
console.log(`Envelope was created. EnvelopeId ${envelopeId}`);
return { envelopeId: envelopeId };
};

Related

Power Query connector - pagination issue

I am new to PQ and I want to get data from REST API.
The API uses pagination and in the 1st quary it returns two fileds. Table contains only 100 records.
IssueList = Table
NextBookmark = value
The url /issues?bookmark=[value] to get another page of issues.
I am trying to use https://learn.microsoft.com/en-us/power-query/samples/trippin/1-odata/readme tutorial to create connector but fails to get values from another page.
Code below:
Table.GenerateByPage = (getNextPage as function) as table =>
let
listOfPages = List.Generate(
() => getNextPage(null), // get the first page of data
(lastPage) => lastPage <> null, // stop when the function returns null
(lastPage) => getNextPage(lastPage) // pass the previous page to the next function call
),
// concatenate the pages together
tableOfPages = Table.FromList(listOfPages, Splitter.SplitByNothing(), {"Column1"}),
firstRow = tableOfPages{0}?
in
// if we didn't get back any pages of data, return an empty table
// otherwise set the table type based on the columns of the first page
if (firstRow = null) then
Table.FromRows({})
else
Value.ReplaceType(
Table.ExpandTableColumn(tableOfPages, "Column1", Table.ColumnNames(firstRow[Column1])),
Value.Type(firstRow[Column1])
);
GetAllPagesByNextLink = (url as text) as table =>
Table.GenerateByPage((previous) =>
let
// if previous is null, then this is our first page of data
nextLink = if (previous = null) then url else Value.Metadata(previous)[NextLink]?,
// if NextLink was set to null by the previous call, we know we have no more data
page = if (nextLink <> null) then GetPage(nextLink) else null
in
page
);
GetPage = (url as text) as table =>
let
response = Web.Contents(url, [ Headers = DefaultRequestHeaders ]),
body = Json.Document(response),
nextLink = GetNextLink(body),
data = Table.FromRecords(body[IssueList])
in
data meta [NextLink = nextLink];
GetNextLink = (response) as nullable text => Record.FieldOrDefault(response[NextBookmark], "NextBookmark");
PQ.Feed = (url as text) as table => GetAllPagesByNextLink(url);
Can anyone help me out?
Thanks in advance for words of advice :)

PowerBi Api - How to get GroupId and DatasetId of Dashboard via API

I have been reading https://powerbi.microsoft.com/en-us/blog/announcing-data-refresh-apis-in-the-power-bi-service/
In this post, it mentions "To get the group ID and dataset ID, you can make a separate API call".
Does anybody know how to do this from the dashboard URL, or do I have to embed the group id and dataset id in my app alongside the dashboard URL???
To get the group ID and dataset ID, you can make a separate API call.
This sentence isn't related to a dashboard, because in one dashboard you can put visuals showing data from many different datasets. These different API calls are Get Groups (to get list of groups, find the one you want and read it's id) and Get Datasets In Group (to find the dataset you are looking for and read it's id).
But you should already know the groupId anyway, because the dashboard is in the same group.
Eventually, you can get datasetId from particular tile using Get Tiles In Group, but I do not know a way to list tiles in dashboard using the Rest API.
This is a C# project code to get the dataset id from Power BI.
Use the below method to call the 'Get' API and fetch you the dataset Id.
public void GetDatasetDetails()
{
HttpResponseMessage response = null;
HttpContent responseContent = null;
string strContent = "";
PowerBIDataset ds = null;
string serviceURL = "https://api.powerbi.com/v1.0/myorg/admin/datasets";
Console.WriteLine("");
Console.WriteLine("- Retrieving data from: " + serviceURL);
response = client.GetAsync(serviceURL).Result;
Console.WriteLine(" - Response code received: " + response.StatusCode);
try
{
responseContent = response.Content;
strContent = responseContent.ReadAsStringAsync().Result;
if (strContent.Length > 0)
{
Console.WriteLine(" - De-serializing DataSet details...");
// Parse the JSON string into objects and store in DataTable
JavaScriptSerializer js = new JavaScriptSerializer();
js.MaxJsonLength = 2147483647; // Set the maximum json document size to the max
ds = js.Deserialize<PowerBIDataset>(strContent);
if (ds != null)
{
if (ds.value != null)
{
foreach (PowerBIDatasetValue item in ds.value)
{
string datasetID = "";
string datasetName = "";
string datasetWeburl = "";
if (item.id != null)
{
datasetID = item.id;
}
if (item.name != null)
{
datasetName = item.name;
}
if (item.qnaEmbedURL != null)
{
datasetWeburl = item.qnaEmbedURL;
}
// Output the dataset Data
Console.WriteLine("");
Console.WriteLine("----------------------------------------------------------------------------------");
Console.WriteLine("");
Console.WriteLine("Dataset ID: " + datasetID);
Console.WriteLine("Dataset Name: " + datasetName);
Console.WriteLine("Dataset Web Url: " + datasetWeburl);
} // foreach
} // ds.value
} // ds
}
else
{
Console.WriteLine(" - No content received.");
}
}
catch (Exception ex)
{
Console.WriteLine(" - API Access Error: " + ex.ToString());
}
}
points to remember:
Make sure these classes exist in your project
PowerBIDataset is a class with List
PowerBIDatasetValue is a class with id, name and webUrl (all string data type) data members
provide below constants in your project class
const string ApplicationID = "747d78cd-xxxx-xxxx-xxxx-xxxx";
// Native Azure AD App ClientID -- Put your Client ID here
const string UserName = "user2#xxxxxxxxxxxx.onmicrosoft.com";
// Put your Active Directory / Power BI Username here (note this is not a secure place to store this!)
const string Password = "xyxxyx";
// Put your Active Directory / Power BI Password here (note this is not secure pace to store this! this is a sample only)
call this GetDatasetDetails() method in the Main method of your project class
and finally
use the below 'Get' API to get the Group Id
https://api.powerbi.com/v1.0/myorg/groups

Alfresco WS Client API - WSSecurityException when using fetchMore method

Can someone tell me what's wrong with my code here... I'm always getting this exception on the first call to contentService.read(...) after the first fetchMore has occurred.
org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized
// Here we're setting the endpoint address manually, this way we don't need to use
// webserviceclient.properties
WebServiceFactory.setEndpointAddress(wsRepositoryEndpoint);
AuthenticationUtils.startSession(wsUsername, wsPassword);
// Set the batch size in the query header
int batchSize = 5000;
QueryConfiguration queryCfg = new QueryConfiguration();
queryCfg.setFetchSize(batchSize);
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
repositoryService.setHeader(new RepositoryServiceLocator().getServiceName().getNamespaceURI(), "QueryHeader", queryCfg);
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
String luceneQuery = buildLuceneQuery(categories, properties);
// Call the repository service to do search based on category
Query query = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery);
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, true);
String querySession = queryResult.getQuerySession();
while (querySession != null) {
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
for (ResultSetRow row : rows) {
// Read the content from the repository
Content[] readResult = contentService.read(new Predicate(new Reference[] { new Reference(STORE, row.getNode().getId(), null) },
STORE, null), Constants.PROP_CONTENT);
Content content = readResult[0];
[...]
}
// Get the next batch of results
queryResult = repositoryService.fetchMore(querySession);
// process subsequent query results
querySession = queryResult.getQuerySession();
}

Zend Framework Reg Ex not working on update form

I have a client input form that has the following two reg expressions that works when creating a client but not when updating a client. The update form is a class that extends the crate form.
// Create text input for mobile
$mobile = new Zend_Form_Element_Text ('mobile');
$mobile->setLabel ('Mobile Number:')
->setDescription('Enter mobile in the format 353XXYYYYYYY')
->setOptions(array('size'=>'14'))
->setRequired(false)
->addValidator('Regex',false,array(
'pattern'=>'/^\d{12}$/',
'messages'=>array(
Zend_Validate_Regex::INVALID => '\'%value%\' Invalid mobile number it does not match the required format 353XXYYYYYYY',
Zend_Validate_Regex::NOT_MATCH =>'\'%value%\'does not match the required format 353XXXXXXXX')
)
)
->addFilter('HtmlEntities')
->addFilter('StringTrim');
// Create text input for landline
$landline = new Zend_Form_Element_Text ('landLine');
$landline->setLabel ('Phone Number:')
->setDescription('Enter phone number in the format +353(0) X YYY YYYZ')
->setOptions(array('size'=>'20'))
->setRequired(false)
->addValidator('StringLength', false, array('min' => 8))
->addValidator('Regex', false, array(
'pattern' => '/^\+353\(0\)\s\d\s\d{3}\s\d{3,4}$/',
'messages' => array(
Zend_Validate_Regex::INVALID =>
'\'%value%\' In valid Phone number does not match required number format +353(0) X YYY YYYZ',
Zend_Validate_Regex::NOT_MATCH =>
'\'%value%\' does not match required number format of +353(0) X YYY YYYZ'
)
))
->addFilter('HtmlEntities')
->addFilter('StringTrim');
When I enter an invalid mobile or land line number when creating a client the reg expression works and prevents the record from being saved.
However when I enter an invalid mobile or land line number when updating a client the reg expression fails and an 404 error occurs.
I think that the issue may be related to the get section of my update action within my controller as shown below but I can't figure out what is causing this as the route I have configured in my ini file retrieves the record as required.
public function updateAction(){
// generate input form
$form = new PetManager_Form_UpdateClient;
$this->view->form=$form;
/* if the requrest was made via post
test if the input is valid
retrieve current record
update values and save to DB */
if($form->isValid($this->getRequest()->getPost())){
$input=$form->getValues();
$client = Doctrine::getTable('PetManager_Model_Clients')
->find($input['clientid']);
$client->fromArray($input);
if($client->email=='')
{$client->email=NULL;}
if($client->mobile=='')
{$client->mobile=NULL;}
if($client->landLine=='')
{$client->landLine=NULL;}
if($client->address3=='')
{$client->address3=NULL;}
$client->save();
$sessionClient = new Zend_Session_Namespace('sessionClient');
$id = $client->clientid;
$fname = $client->firstName;
$lname = $client->lastName;
$sessionClient->clientid=$id;
$sessionClient->clientfName=$fname;
$sessionClient->clientlName=$lname;
$sessionClient->clientfName=$fname;
$this->_helper->getHelper('FlashMessenger')
->addMessage('The record for '.$fname.' '.$lname. ' was successfully updated.');
$this->_redirect('clients/client/success');
}else{
/* if GET request
set filters and validators for GET input
test if input is valid, retrieve requested
record and pree-populate the form */
$filters = array(
'id'=>array('HtmlEntities','StripTags','StringTrim')
);
$validators = array(
'id'=>array('NotEmpty','Int')
);
$input = new Zend_Filter_Input($filters,$validators);
$input->setData($this->getRequest()->getParams());
if($input->isValid()){
$qry = Doctrine_Query::create()
->from('PetManager_Model_Clients c')
->leftJoin('c.PetManager_Model_Counties co')
->where('c.clientid=?',$input->id);
$result = $qry->fetchArray();
if(count($result)==1){
$this->view->form->populate($result[0]);
}else{
throw new Zend_Controller_Action_Exception('Page not found',404);
}
}else{
throw new Zend_Controller_Action_Exception('Invalid Input');
}
}
}
All help greatly appreciated.
Ok I've sorted this I stupidly left out a check in my update action to see if the request was being made by post as this is the action defined in my form.
The corrected code is shown below in case this helps anyone else.
// action to update an individual clients details
public function updateAction()
{
// generate input form
$form = new PetManager_Form_UpdateClient;
$this->view->form=$form;
/* if the requrest was made via post
test if the input is valid
retrieve current record
update values and save to DB */
if ($this->getRequest()->isPost()) {
if($form->isValid($this->getRequest()->getPost())){
$input=$form->getValues();
$client = Doctrine::getTable('PetManager_Model_Clients')
->find($input['clientid']);
$client->fromArray($input);
if($client->email=='')
{$client->email=NULL;}
if($client->mobile=='')
{$client->mobile=NULL;}
if($client->landLine=='')
{$client->landLine=NULL;}
if($client->address3=='')
{$client->address3=NULL;}
$client->save();
$sessionClient = new Zend_Session_Namespace('sessionClient');
$id = $client->clientid;
$fname = $client->firstName;
$lname = $client->lastName;
$sessionClient->clientid=$id;
$sessionClient->clientfName=$fname;
$sessionClient->clientlName=$lname;
$sessionClient->clientfName=$fname;
$this->_helper->getHelper('FlashMessenger')
->addMessage('The record for '.$fname.' '.$lname. ' was successfully updated.');
$this->_redirect('clients/client/success');
}
}else{
/* if GET request
set filters and validators for GET input
test if input is valid, retrieve requested
record and pree-populate the form */
$filters = array(
'id'=>array('HtmlEntities','StripTags','StringTrim')
);
$validators = array(
'id'=>array('NotEmpty','Int')
);
$input = new Zend_Filter_Input($filters,$validators);
$input->setData($this->getRequest()->getParams());
if($input->isValid()){
$qry = Doctrine_Query::create()
->from('PetManager_Model_Clients c')
->leftJoin('c.PetManager_Model_Counties co')
->where('c.clientID=?',$input->id);
$result = $qry->fetchArray();
if(count($result)==1){
$this->view->form->populate($result[0]);
}else{
$t=count($result);
throw new Zend_Controller_Action_Exception('Page not found',404);
}
}else{
throw new Zend_Controller_Action_Exception('Invalid Input');
}
}
}

Problem Binding to GridView HiddenField

EDIT: I added in the hf from the first reply that was pointed out. This helped with a few other issues, but still did not fix the problem.
I am trying to bind a list to a gridview with a LOT of hidden fields (I'll only use 2 of the 50) for temporary holding so the user can create and delete multiple items without going back and forth to the database multiple times during creation. I'm fine with binding to and recalling from the BoundFields; however, when I try to recall the hidden field values it comes back as null. I may be having problems with the binding to the hidden fields. Here's my code
ASP:
<asp:GridView ID="grdOtherCarrier" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="Sequence" DataField="Sequence"></asp:BoundField>
<asp:BoundField HeaderText="Pay ID" DataField="PayID"></asp:BoundField>
<asp:BoundField HeaderText="Provider" DataField="Provider"></asp:BoundField>
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<asp:HiddenField ID="hfInsuredLastName" Value="<%#Eval("InsuredLastName")%>" runat="server" />
<asp:HiddenField ID="hfInsuredFirstName" Value="<%#Eval("InsuredFirstName")%>" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
C# / code behind:
protected void lblSubmitOtherCarrier_Click(object sender, EventArgs e)
{
List<OtherCarrier> OCList = new List<OtherCarrier>();
OtherCarrier OC;
foreach (GridViewRow row in grdOtherCarrier.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
OC = new OtherCarrier();
String Sequence = row.Cells[0].Text.ToString() ; // primary value
String PayID = row.Cells[1].Text.ToString(); // primary value
String Provider = row.Cells[2].Text.ToString(); // primary value
HiddenField InsuredLastName = (HiddenField)row.FindControl("hfInsuredLastName");
HiddenField InsuredFirstName = (HiddenField)row.FindControl("hfInsuredFirstName");
OC.Sequence = Sequence;
OC.PayID = PayID;
OC.Provider = Provider;
OC.InsuredLastname = InsuredLastName.Value.ToString();
OC.InsuredFirstName = InsuredFirstName.Value.ToString();
OCList.Add(OC);
}
}
OC = new OtherCarrier();
OC.Sequence = txtSequence.Text;
OC.PayID = txtPayID.Text;
OC.Provider = txtProvider.Text;
OC.InsuredLastname = txtInsuredLastname.Text;
OC.InsuredFirstName = txtInsuredFirstName.Text;
OCList.Add(OC);
TD.OtherCarrierList = OCList;
grdOtherCarrier.DataSource = OCList;
grdOtherCarrier.DataBind();
mpeAddOtherCarrier.Hide();
txtSequenceNo.Text = (grdOtherCarrier.Rows.Count + 1).ToString();
}
When it gets to assigning the OC.InsuredLastname from the hidden field the hidden field is coming up as null value. Either I'm not reading it correctly or it's not being written correctly.
so...
you are trying to find a control as
(HiddenField)row.FindControl("InsuredLastName");
as you can see, named InsuredLastName when you explicit say in the HTML that your control name is:
<asp:HiddenField
ID="hfInsuredLastName"
Value="<%#Eval("InsuredLastName")%>"
runat="server" />
named hfInsuredLastName
all you need to do is change the call to
(HiddenField)row.FindControl("hfInsuredLastName")