url sharepoint list camlquery - wpf

I'm trying to collect my url and the description of the url stored in a column of a list from sharepoint and i don't know how to collect the URL value.
This is my code :
var queryResultSaleListItems = clientContext.LoadQuery(listData);
clientContext.ExecuteQuery();
//Read the Data into the Object
var TipsList = from Tips in queryResultSaleListItems
select Tips;
ObservableCollection<Tips> colTips = new ObservableCollection<Tips>();
//Read Every List Item and Display Data into the DataGrid
foreach (SPSClient.ListItem item in TipsList)
{
var tips = new Tips();
tips.TitleTip = item.FieldValues.Values.ElementAt(1).ToString();
tips.App = item.FieldValues.Values.ElementAt(4).ToString();
//should collect the url
tips.URL = item.FieldValues.Values.ElementAt(5).ToString();
//should collect the description of the url
tips.URLdesc = item.FieldValues.Values.ElementAt(5).ToString();
colTips.Add(tips);
}
ListboxTips.DataContext = colTips;
In my expression its >
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Url
((Microsoft.SharePoint.Client.FieldUrlValue)(item.FieldValues.Values.ElementAt(5))).Description
Thanks for your help,

Use FieldUrlValue for getting hyperlink field in Client Object Model.
Use Following Code:
string server = "siteURL";
var ctx = new ClientContext(server);
var web = ctx.Web;
var list = web.Lists.GetByTitle("CustomList");
var listItemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(listItemCollection);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItemCollection)
{
string acturlURL = ((FieldUrlValue)(listItem["URL"])).Url.ToString(); // get the Hyperlink field URL value
string actdesc = ((FieldUrlValue)(listItem["URL"])).Description.ToString(); // get the Hyperlink field Description value
}

Related

Salesforce updating metadata record using apex

'I am trying to update a salesforce metadata record via Apex. here is my code:
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
for(Omni_Routing_Skillset__mdt md: omnimetadata) {
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = md.DeveloperName; //custom metadata name
customMetadata.Label = md.MasterLabel;
Metadata.CustomMetadataValue customField1 = new Metadata.CustomMetadataValue(); //the values you're changing/updating
customField1.field = 'Omni_Routing_Skillset__mdt.Skill_Level__c'; //the custom field API Name that you're wanting to insert/update a value of
customField1.value = skillsAndValues.get(md.MasterLabel);
customMetadata.values.add(customField1);//add the changes to list of changes to be deployed
mdContainer.addMetadata(customMetadata);
System.debug('customMetadata: ' + customMetadata);
}
//MetadataDeploy callback = new MetadataDeploy();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, null);
This kicks off the deployment but i get the following error:
**Must specify the name in the CustomMetadataType.CustomMetadata format, Current Name: Team_2_SEP, Required Delimiter: .**
I am not sure how to fix this, can anyone please advise?
Thanks!
The name would be Omni_Routing_Skillset__mdt.Team_2_SEP you're only passing in Team_2_SEP.
You can reference this method:
public static void updateExisitingMetadatRecord() {
List<Metadata_Creditional__mdt> metadatList = [SELECT Id, DeveloperName,
MasterLabel FROM Metadata_Creditional__mdt WHERE DeveloperName='MyTest'];
Metadata.CustomMetadata metadataRec = new Metadata.CustomMetadata();
metadataRec.fullName =
'Metadata_Creditional__mdt.'+metadatList[0].DeveloperName;
metadataRec.label = metadatList[0].MasterLabel;
//provide the value for the fields and add it to custom metadata instance
Metadata.CustomMetadataValue totalPurchasetoUpdate = new
Metadata.CustomMetadataValue();
totalPurchasetoUpdate.field = 'Secret_Key__c';
totalPurchasetoUpdate.value = 'Change Secreet Value';
metadataRec.values.add(totalPurchasetoUpdate);
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(metadataRec);
Metadata.Operations.enqueueDeployment(mdContainer, null);
}

Anchor tags are not showing up in the document

Anchor tags are not showing up in the document
We have a 14 page document where the users will have to sign at the end of the Document on the field specified. The Document pdf looks like '
Where near the By field I have /s1/ tag which is invisible. And also in the Docusign custom button Controller I have the code like
................
Attachment att = [Select id,Name,Body,parentid from Attachment where parentid =: OppLst.id order by createddate DESC LIMIT 1 ];
DocuSignTK.Document document = new DocuSignTK.Document();
document.ID = 1;
document.Name = 'Quote Document';
document.FileExtension = 'html';
document.pdfBytes = EncodingUtil.base64Encode(attach.Body);
DocuSignTK.Recipient recipient = new DocuSignTK.Recipient();
recipient.Email = 'dh#gmail.com';
recipient.UserName = 'Dh';
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
// The signer tab...
DocuSignTK.Tab signHereTab = new DocuSignTK.Tab();
signHereTab.Type_x = 'SignHere';
signHereTab.AnchorTabItem = new DocuSignTK.AnchorTab();
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
signHereTab.AnchorTabItem.XOffset = 8;
signHereTab.RecipientID = 1;
signHereTab.Name = 'Please sign here';
signHereTab.ScaleValue = 1;
signHereTab.TabLabel = 'signer1sig';
// The dateSigned tab
DocuSignTK.Tab dateSignedTab = new DocuSignTK.Tab();
dateSignedTab.Type_x = 'DateSigned';
dateSignedTab.AnchorTabItem = new DocuSignTK.AnchorTab();
dateSignedTab.AnchorTabItem.AnchorTabString = 'signer1date';
dateSignedTab.AnchorTabItem.YOffset = -6;
dateSignedTab.RecipientID = 1;
dateSignedTab.Name = 'Date Signed';
dateSignedTab.TabLabel = 'date_signed';
// Create an envelope and fill it in
DocuSignTK.Envelope envelope = new DocuSignTK.Envelope();
envelope.Subject = 'Please sign the Quote Document';
envelope.AccountId = account_id;
envelope.Tabs = new DocuSignTK.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignTK.Tab[2];
envelope.Tabs.Tab.add(signHereTab);
envelope.Tabs.Tab.add(dateSignedTab);
envelope.Recipients = new DocuSignTK.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignTK.Recipient[1];
envelope.Recipients.Recipient.add(recipient);
envelope.Documents = new DocuSignTK.ArrayOfDocument();
envelope.Documents.Document = new DocuSignTK.Document[1];
envelope.Documents.Document.add(document);
if (String.isNotBlank(email_message))
{
envelope.EmailBlurb = email_message;
}
In the Docusign email it doesn't show anything
How to make the tags available so it is easy for the user to click and Sign.
the string that you use in your document to "anchor" the tabs should be the same that you specify in your tab AnchorTabString property.
You mentioned that the document has an invisible /s1/ tag in the text, but it looks like in your code you are setting a different value for the anchor string:
signHereTab.AnchorTabItem.AnchorTabString = 'signer1sig';
if you update this value to match the /s1/ value in your document it should work.
One way to troubleshoot this would be to log into your DocuSign account, create a new envelope using the document above, add a recipient and go to the tagger page.
Once in the tagger page you can use the "auto-place" feature, which is the same as the anchor strings, to test that the string that you want to use as an anchor can be found in the document.
Once you verify that you have the right string, you could use that string in your API call and things should work.
How to use the auto-place feature:
https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience

Validation xpages file download control

I have to do a validation in component file download Control, checking if any file is listed. Does anyone know how to do this validating. How can I get the object representing the xpages component and list the files by any of its methods?
here is some code I use to get hold on the upload via ssjs (if you want that)
var con = facesContext.getExternalContext();
var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest();
var fileDataName = getClientId('ctrlUpload') ;
var map:java.util.Map = request.getParameterMap();
var fileData:com.ibm.xsp.http.UploadedFile = map.get(fileDataName);
if( fileData == null ){
growl.createGrowlMessage("<strong>Warning</strong> no file to upload selected","danger");
return;
}
var tempClientFile = fileData.getClientFileName();
var tempFile:java.io.File = fileData.getServerFile();
var filePath = tempFile.getParentFile().getAbsolutePath();
var correctedFile = new java.io.File(filePath+java.io.File.separator + tempClientFile );
var success = tempFile.renameTo(correctedFile);
var doc:NotesDocument = attachDoc.getDocument(true);
var rtFiles:NotesRichTextItem = null;
if(!(doc.hasItem("Files"))){
rtFiles = doc.createRichTextItem("Files");
}else{
rtFiles = doc.getFirstItem("Files");
}
rtFiles.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT,"",correctedFile.getAbsolutePath(), null);
correctedFile.renameTo(tempFile);
attachDoc is the reference to the data-binding I have set up:
<xp:this.data>
<xp:dominoDocument formName="fa_Attachment"
var="attachDoc">
</xp:dominoDocument>
</xp:this.data>

Unable to send attachment - Salesforce Docusign API

I am trying to send attachment (record has one attachment) in opportunity record via Apex and Docusign "CreateAndSendEnvelope" API.
But I am getting this error "The DocuSign EnvelopeId:Exception - System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx"
Below is the piece of code used.
// Render the contract
System.debug('Rendering the contract');
PageReference pageRef = new PageReference('/apex/RenderContract');
pageRef.getParameters().put('id',contract.Id);
//Blob pdfBlob = pageRef.getContent();
Attachment att = [SELECT Id, Name, Body, ContentType FROM Attachment WHERE Parentid = :contract.Id LIMIT 1];
Blob pdfBlob = att.Body;
// Document
DocuSignAPI.Document document = new DocuSignAPI.Document();
document.ID = 1;
document.pdfBytes = EncodingUtil.base64Encode(pdfBlob);
document.Name = 'Contract';
document.FileExtension = 'pdf';
envelope.Documents = new DocuSignAPI.ArrayOfDocument();
envelope.Documents.Document = new DocuSignAPI.Document[1];
envelope.Documents.Document[0] = document;
// Recipient
System.debug('getting the contact');
Contact contact = [SELECT email, FirstName, LastName
from Contact where id = :contract.CustomerSignedId];
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = 1;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 1;
recipient.Email = contact.Email;
recipient.UserName = contact.FirstName + ' ' + contact.LastName;
// This setting seems required or you see the error:
// "The string '' is not a valid Boolean value.
// at System.Xml.XmlConvert.ToBoolean(String s)"
recipient.RequireIDLookup = false;
envelope.Recipients = new DocuSignAPI.ArrayOfRecipient();
envelope.Recipients.Recipient = new DocuSignAPI.Recipient[1];
envelope.Recipients.Recipient[0] = recipient;
// Tab
DocuSignAPI.Tab tab1 = new DocuSignAPI.Tab();
tab1.Type_x = 'SignHere';
tab1.RecipientID = 1;
tab1.DocumentID = 1;
tab1.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab1.AnchorTabItem.AnchorTabString = 'By:';
DocuSignAPI.Tab tab2 = new DocuSignAPI.Tab();
tab2.Type_x = 'DateSigned';
tab2.RecipientID = 1;
tab2.DocumentID = 1;
tab2.AnchorTabItem = new DocuSignAPI.AnchorTab();
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
envelope.Tabs = new DocuSignAPI.ArrayOfTab();
envelope.Tabs.Tab = new DocuSignAPI.Tab[2];
envelope.Tabs.Tab[0] = tab1;
envelope.Tabs.Tab[1] = tab2;
System.debug('Calling the API');
try {
DocuSignAPI.EnvelopeStatus es
= dsApiSend.CreateAndSendEnvelope(envelope);
envelopeId = es.EnvelopeID;
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
envelopeId = 'Exception - ' + e;
}
Any ideas how to overcome this error?
Thanks.
The Original Poster's (OP's) comment is
it worked fine on rendering the whole record to pdf...but now i tried sending attachments only instead of whole record.. i started to get this error.
So my guess is that the envelope request has a document problem.
Best way to debug: see what is being sent to the DocuSign platform.
Try the beta API logger or the regular logger. Then add the log to your question by editing your question.
This problem came across me with same error .
" An Error Occurred during anchor tag processing. Invalid document faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx "
you need to replace anchor tab string with desired string given in your attached document where signature is required.
Replace :
tab1.AnchorTabItem.AnchorTabString = 'By:';
tab2.AnchorTabItem.AnchorTabString = 'Date Signed:';
To :
tab1.AnchorTabItem.AnchorTabString = 'Signature label in your document';
tab2.AnchorTabItem.AnchorTabString = 'Signature label in your document';

Search data in mongodb according to field values

I am using mongodb and node.js. In my database i have 6 fields that is
bid
color (Array)
size (Array)
cat_id
sub_cat_id
All is working fine. Now i want to add filter in my code. In filter area i have add this all fields. user select multiple colors and sizes so it will come in Array format but most of the time user will not select color option or size option at that time field values comes blank so my filter will not take any result from database. so i want to remove color or size field if value is empty during search. I have tried below code but its not working.how i do this.
var catId = new Array();
var sort = saveFilterSort.sort;
var filter = req.body;
if(req.body.catId){
catId.push("category_id:"+req.body.catId);
}
if(req.body.subcatid){
catId.push("sub_category_id:"+req.body.subcatid);
}
if(req.body.minprice){
catId.push("price:{$gt:"+req.body.minprice+"}");
}
if(req.body.maxprice){
catId.push("price:{$lt:"+req.body.maxprice+"}");
}
if(req.body.color){
catId.push("color:{$in:"+req.body.color+"}");
}
if(req.body.size){
catId.push("attribute:{$in:"+req.body.size+"}");
}
var finalCat = catId.join(',');
console.log(finalCat);
console.log(catId);
if((filter) && (sort)){
Product.find(
{
brand_id:bid, finalCat
},
function(error,fetchallFeatProds)
{
console.log('#######################');
console.log(fetchallFeatProds);
console.log('#######################');
callback(error,fetchallFeatProds);
}).sort( {_id:-1,price:-1} );
This code is not working. Please help me.
Mongoose find prototype handle json and not string
var query = {brand_id:bid};
var sort = saveFilterSort.sort;
var filter = req.body;
if(req.body.catId){
query.category_id = req.body.catId;
}
if(req.body.subcatid){
query.sub_category_id = req.body.subcatid;
}
if(req.body.minprice){
query.price = {$gt:req.body.minprice};
}
if(req.body.maxprice){
query.price = {$lt:req.body.maxprice};
}
if(req.body.color){
query.color = {$in:req.body.color};
}
if(req.body.size){
query.attribute = {$in:req.body.size};
}
if((filter) && (sort)){
Product.find(query, ...

Resources