Cascade Drop-Dow in Shareponint 2013 not working - sharepoint

I have two lists:
Clientes-Canal: TITLE
Clientes-Subsegmentacion: TITLE - CANAL (Lookup to Clientes-Canal)
Clientes: where I save all the information
My code:
$(document).ready(function () {
$().SPServices.SPCascadeDropdowns({
relationshipList: "Clientes-Subsegmentacion",
relationshipListParentColumn: "Clientes-Canal",
relationshipListChildColumn: "Title",
parentColumn: "Canal",
childColumn: "Subsegmentacion",
debug: true
});
});
In my Clientes' list I have two columns, Canal (Lookup to Clientes-Canal), and Subsegmentacion (Lookup to Clientes-Subsegmentacion)
But it's not working.
Error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Here are the docs:
relationshipList The name or GUID of the list which contains the
parent/child relationships. If you choose to use the GUID, it should
look like: "{E73FEA09-CF8F-4B30-88C7-6FA996EE1706}". Note also that if
you use the GUID, you do not need to specify the relatedWebURL if the
list is in another site.
relationshipListParentColumn The StaticName of the parent column in
the relationshipList
relationshipListChildColumn The StaticName of the child column in the
relationshipList
parentColumn The DisplayName of the parent column in the form
childColumn The DisplayName of the child column in the form
So, in your case:
$(document).ready(function(){
$().SPServices.SPCascadeDropdowns({
relationshipList: "Clientes-Subsegmentacion",
relationshipListParentColumn: "Canal",
relationshipListChildColumn: "Title",
parentColumn: "Canal",
childColumn: "Subsegmentacion",
debug: true
});
});
Make sure you don't have spelling mistakes, you can also try using Id of your Clientes-Subsegmentacion list.
Take a look at my answer here on similar question if my answer doesn't help you.

Related

SharePoint list Display Manager name for a user

I'm looking to display the managers name (defined in AD for the user) in a column depending on a selection from another column. For example.
Column 1 - Employee Name
Column 2 - Department
Column 3 - Manager
Column 1 is populated with the employee name and saved. It's a "User or Group" type column
Column 2 is "Person or Group" column with the "Show Field" option set as department. I have a workflow that starts on a new entry that takes the column 1 data and applies it to Column 2 thus display the users department.
My issue is in the "Show Fields" option there is no manager selection. Is there a way to display this as a selection or is there another way for me to populate a users manager depending on the employee selection?
The other option I've tried is doing a 2010 workflow for "Find Manager of" current employee (output to variable:manager) and then to update the manager column to use the data from Variable manager but nothing seems to display.
enter image description here Perhaps I've done something wrong here though..
Any help would be appreciated.
Updated screenshot information
enter image description here
What is the data type of Manager column? Make it 'Person or Group'.
In the workflow, select return field as 'Login Name' and try. Below is the screen shot.
You can get all the three values on the New Form itself and then just save it.
Use SPServices jQuery. Just download the latest one. Below is the script.
<script type="text/javascript" src="/your path to JS/SiteAssets/JS/jquery-3.1.1.js"></script>
<script type="text/jscript" src="/your path to JS/SiteAssets/JS/jquery.SPServices.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var managerName;
var userName = $().SPServices.SPGetCurrentUser();
$().SPServices({
operation: "GetUserProfileByName",
async: false,
AccountName: userName,
completefunc: function (xData, Status)
{
managerName = $(xData.responseXML).text();
var managerLength = managerName.length;
var indexofManager = managerName.indexOf("ManagerPublic");
managerName = managerName.substring(indexofManager+13, managerLength);
var indexOffalse = managerName.indexOf("false");
managerName = managerName.substring(0, indexOffalse);
}
});
var UserDept = $().SPServices.SPGetCurrentUser({
fieldName: "Department",
debug: false
});
var CurrentUser = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});
$("input[title*='Employee Name']").val(CurrentUser); // For assigning to SharePoint column named 'Employee Name'
$("input[title*='Department']").val(UserDept); // For assigning to SharePoint column named 'Department'
var Mgr = $().SPServices.SPFindPeoplePicker({
peoplePickerDisplayName: "Manager", // For assigning to SharePoint column named 'Manager'
valueToSet: managerName,
checkNames: true
});
});
</script>

Query attachment from a Message record

Through the UI, I have created several Message records attached to a Support Ticket record, two of which have file attachments. I have been able to retrieve the ticket, and its related messages in Suitescript - which are correctly reporting hasAttachment as 'T' - but I cannot seem to access the attachments themselves. The documentation states that the attachments are a sublist called 'mediaitem' (or 'mediaitemlist', depending on where you look), but none of the sublist APIs have any success on those names.
var record = nlapiLoadRecord('message', 1092823, {recordmode: 'dynamic'});
var itemCount = record.getLineItemCount('mediaitem');
// returns -1
The documentation and other online info is pretty sparse, so any help would be greatly appreciated.
Yeah, indeed there is a poor documentation. And mediaitem sublist did not help me either to give any meaningful result.
However, there is an alternate solution to it.
Create a saved search from UI on message record type.
Make sure you add a search column Attachments : Internal ID (i.e.
using attachment fields...)
Once, this is done, run your search in suitescript as
var res = nlapiSearchRecord('message', 'YOUR_UI_SEARCH_ID', ARRAY_OF_ADDITIONAL_FITLTERS);
res[i].getValue('internalid', 'attachments')
This is how you can do it in Suitescript 2.0. First search the message ids then search for the attachments related to those message ids. You can create the searches on the fly so no need for saved searches.
You can pass an array of internal ids of cases or messages if you want to save governance points depending on your scenario.
Note: The following code samples assumes that you loaded the search module as SEARCHMODULE.
Step 1 - This is how to get the message ids with attachments from a support case record (just change the type to support ticket):
function getMessageIdsFromCase(supportCaseId){
var supportcaseSearchObj = SEARCHMODULE.create({
type: "supportcase", //Change if you need to
filters: [
["internalid","anyof",supportCaseId],
"AND",
["messages.hasattachment","is","T"]
],
columns: [
SEARCHMODULE.createColumn({
name: "internalid",
join: "messages"
})
]
});
var resultsSet = supportcaseSearchObj.run();
var results = resultsSet.getRange(0, 999);
var messages = [];
for (var i in results) {
var result = results[i];
var message = result.getValue(result.columns[0]);
messages.push(message);
}
return messages;
}
Then you just call the function like this:
getMessageIdsFromCase(caseInternalId); //Returns an array of message ids
Step 2 - Then you search the attachments using the message internal id with this function:
function getAttachmentIdsFromMessage(messageInternalId){
var messageSearchObj = SEARCHMODULE.create({
type: "message",
filters: [
["internalid","anyof",messageInternalId]
],
columns: [
SEARCHMODULE.createColumn({
name: "internalid",
join: "attachments"
})
]
});
var resultsSet = messageSearchObj.run();
var results = resultsSet.getRange(0, 999);
var attachments = [];
for (var i in results) {
var result = results[i];
var attachment = result.getValue(result.columns[0]);
attachments.push(attachment);
}
return attachments;
}
Then you just call the function like this:
getAttachmentIdsFromMessage(messageInternalId); //Returns an array of attachment ids
UPDATE:
heard from NS after submitting a case. Appears this is not supported yet:
Hi Shane,
I hope you are doing well today.
Upon checking, the ability to access files attached to records are not yet supported in SuiteScript. You can check out SuiteScript Records Browser at SuiteAnswers ID 10511 for the full list of all available records in SuiteScripts and each's accessible sublist. Let me know if you have further questions.
Caleb Francisco | Customer Support
NetSuite: Where Business is Going
Using search.createColumn with joins is the key it looks like. I ended up using quick code below this to get any $files (html) attached to $transaction (returnauthorization), which were in my case, supposed to be mediaitems on a return auth that I couldn't get via the record module in ss2.0
var getHtmlFilesOnReturnAuth = function (return_auth_id, file_type) {
var filters = [
search.createFilter({name: "internalid", operator: "is", values: [return_auth_id]}),
search.createFilter({name: "filetype", join: "file", operator: "is", values: [file_type]}),
];
var images = [];
search.create({
type: "returnauthorization",
filters: filters,
columns: [
search.createColumn({name: "internalid", summary: "group"}),
search.createColumn({name: "internalid", join: "file", summary: "group"}),
search.createColumn({name: "filetype", join: "file", summary: "group"}),
search.createColumn({name: "name", join: "file", summary: "group"}),
]
}).run().each(function (result) {
if (result) {
images.push({
id: result.getValue({name: "internalid", join: "file", summary: "group"}),
file_name: result.getValue({name: "name", join: "file", summary: "group"}),
file_type: result.getValue({name: "filetype", join: "file", summary: "group"}),
});
}
return true;
});
return images;
};
var images = getHtmlFilesOnReturnAuth("2134404", "HTMLDOC");

Using SharePoint SPServices

How to set values to a multi choice field using SPServices in SharePoint ?
This Code worked
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "RĂ©sidentiel"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
But if I want to add multiple choice doesn't work
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
webURL: "/sites/ep/",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "RĂ©sidentiel, Business"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
Cible is a Multiple Choice field in a sharepoint List.
Since SPServices is calling the OOB webservices behind the scenes, in theory the standard means of updating multiple choice values should come into play: Delimit the values with ;#
E.g.
";#RĂ©sidentiel;#Business;#"
Note: Order matters. Make sure values are specified in the same order they're defined in the column
I came across this post while trying to achieve the same thing, however this answer didn't work for me. I was eventually able to save multiple values in the lookup field using the following format:
"6;#;#8;#"
Where the numbers are the ID of the list items (to save formatting issues)
With the ID and the title of the list item it looked like this:
"6;#Alcohol:Reports;#4;#Alcohol: News"
Both of these methods successfully inserted the values into the list.

Kendo UI Grid search as type example

I would like to search datagrid in Kendo UI during typing into input field above the grid.
How can I do it?
Thanks for any advice.
Here is example of columns:
$("#grid").kendoGrid({
dataSource: dataPacket,
filterable: true,
pageSize: 10,
pageable: true,
sortable: true,
reorderable: true,
resizable: true,
columnMenu: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: ["id",
"username",
"name",
"surname",
"email",
{
field :"created",
title : "Created at",
format: "{0:M/d/yyyy}",
parseFormats: ["dd-MM-yyyy"],
type: "date"
},
Kendo make this thing really easy for you, what is needed is to create a filter and pass it to the DataSource.
http://docs.telerik.com/kendo-ui/api/framework/datasource#methods-filter
However, this problem must be divided into two different tasks:
a) Capture the key events in the search box, throttle it and start the search "operation".
b) Build a filter and pass it to the DataSource.
So for throttling the keyboard events, we need a timeout. Or use the throttle function from underscorejs. Why? We don't wanna trigger a search operation on each key press. Only 250 milliseconds (this number is up to you) after the last keystroke.
Here is your sample HTML
<input type="text" id="search" />
Here is your sample script. I wrap everything as a self calling function as you don't wanna create a mess declaring global variables.
(function($, kendo){
// ID of the timeout "timer" created in the last key-press
var timeout = 0;
// Our search function
var performSearch = function(){
// Our filter, an empty array mean "no filter"
var filter = [];
// Get the DataSource
var dataSource = $('#grid').data('kendoGrid').dataSource;
// Get and clean the search text.
var searchText = $.trim($('#search').val());
// Build the filter in case the user actually enter some text in the search field
if(searchText){
// In this case I wanna make a multiple column search so the filter that I want to apply will be an array of filters, with an OR logic.
filter.push({
logic: 'or',
filters:[
{ field: 'username', operator: 'contains', value: searchText },
{ field: 'name', operator: 'contains', value: searchText },
{ field: 'surname', operator: 'contains', value: searchText },
{ field: 'email', operator: 'contains', value: searchText }
]
});
}
// Apply the filter.
dataSource.filter(filter);
};
// Bind all the keyboard events that we wanna listen to the search field.
$('#search').on('keyup, keypress, change, blur', function(){
clearTimeout(timeout);
timeout = setTimeout(performSearch, 250);
});
})(window.jQuery, window.kendo);
Bottom-line: Make sure you are using the right DataSource configuration.
If you configured serverFiltering = true, this filtering logic will be part of your Ajax request, so your server will have to interpret and perform the filtering on server-side.
In case you configured serverFiltering = false all this filtering logic will be evaluated on client side using JavaScript (damn fast!). And in this case, the schema (what data-type is expected on each column) must be also well-configured.

extjs search box

I'm, trying to add a search box exactly as one on sencha docs home page http://docs.sencha.com/ext-js/4-0/
I used the code from the example
http://docs.sencha.com/ext-js/4-0/#!/example/form/forum-search.html
and everything works as expected except for one thing ..
when I select an option from a list in my search box the combobox value is set to the selected value .. and when I press arrow down button it performs a new search with modified query ..
but I just want to see the results of the previous search - exactly the behaviour of the search box on sencha page
any ideas how to achieve that ?
After trying various things the code below does what i need, but maybe there is a better way ..
I had to set triggerAction to 'query' and also had to manually reset the text of the combobox in the the select event handler
var searchBox = {
xtype: 'combo',
store: dataStore,
displayField: 'title',
valueField: 'id',
autoSelect: false,
typeAhead: false,
fieldLabel: 'Search for',
hideTrigger:true,
anchor: '100%',
mode:'remote',
triggerAction: 'query',
listeners: {
'select' : function(combo) {
var selected = this.value;
combo.setValue(combo.lastQuery);
showResult(selected);
}
},
listConfig: {
loadingText: 'Searching ...',
emptyText: 'No matching posts found.',
getInnerTpl: function() {
return '<a class="search-item" href="?term={id}" onclick="return javascript:showResult(\'{id}\')">' +
'<h3><span>{title}<br /></span>{id}</h3></a>';
}
},
pageSize: 10
}
You need first sample from this page. Type "A" first
http://docs.sencha.com/ext-js/4-0/#!/example/form/combos.html

Resources